#######################################################################################################################
# File Name  : Global.Makefile.target.make.3                                                                          #
# Description: This makefile implements the common features of each project. It is included by the project local file #
#              "Makefile", which contains the project specific settings (platform, compiler).                         #
#                                                                                                                     #
#               This file MUST NOT BE CHANGED on project integration                                                  #
#                                                                                                                     #
# Project    : Vector PES Buildenvironment                                                                            #
# Module     : GlobalMake 3.13                                                                                        #
#                                                                                                                     #
#---------------------------------------------------------------------------------------------------------------------#
# COPYRIGHT                                                                                                           #
#---------------------------------------------------------------------------------------------------------------------#
# Copyright (c) 2018 by Vector Informatik GmbH.                                                  All rights reserved. #
#                                                                                                                     #
#---------------------------------------------------------------------------------------------------------------------#
# AUTHOR IDENTITY                                                                                                     #
#---------------------------------------------------------------------------------------------------------------------#
# Name                          Initials      Company                                                                 #
# ----------------------------  ------------  ------------------------------------------------------------------------#
# Benjamin Walter               visbwa        Vector Informatik GmbH                                                  #
# Roland Reinl                  virrro        Vector Informatik GmbH                                                  #
# Matthias Gette                visget        Vector Informatik GmbH                                                  #
# Jens Haerer                   visjhr        Vector Informatik GmbH                                                  #
# Andre Caspari                 visci         Vector Informatik GmbH                                                  #
# Steffen Frank                 visfsn        Vector Informatik GmbH                                                  #
# Andreas Hahn                  vishan        Vector Informatik GmbH                                                  #
# Viet Duc Nguyen               visvnn        Vector Informatik GmbH                                                  #
# Michael Tiran                 vismin        Vector Informatik GmbH                                                  #
#---------------------------------------------------------------------------------------------------------------------#
# REVISION HISTORY                                                                                                    #
#---------------------------------------------------------------------------------------------------------------------#
# Version   Date        Author  Description                                                                           #
# --------  ----------  ------  --------------------------------------------------------------------------------------#
# 03.13.00  2015-11-04  visbwa  New branch, initially based on version 3.12.04 Removed QUICKBUILD fragments (outdated #
#                               feature), added support for VTTonly Deliverydesriptiongeneration (static              #
#                               makesupport.xml file), deleted outdated build targets: version, visual, visual7,      #
#                               visual8, visual9, visual11, os, build.xml removed outdated MacroAssembler             #
#                               functionality, SKIP_BRSVINFO usage changed to BRSVINFO_USED, removed static           #
#                               MODULE_LIST_* lists (MPPD part!), removed usage of BRS_DATA,ZBRS_DATA,ZBRS_COMMON,    #
#                               moved PC-Lint defaults into Makefile.analysis, fixed CPU_TYPE/DERIVATIVE and v_cfg.h  #
#                               handling, introduced NANT_USED                                                        #
# 03.13.01  2015-12-15  visbwa  Added target dd (same as deliverydescription), fixed makesupport.xml CFLAGS-usage     #
# 03.13.02  2016-03-11  visbwa  fixed support for Autosar OS (Module List)                                            #
# 03.13.03  2016-03-17  visbwa  Readded kBrsCompilerDef and kBrsControllerDef to BrsVInfo.h generation (used by CBD   #
#                               BrsCtrl.c)                                                                            #
# 03.13.04  2016-03-29  visbwa  Added $(PROJECT_NAME).hex to DEL_PATTERN_LIST                                         #
# 03.13.05  2016-03-29  virrro  Adapted link rule to wait for finished linkscript generation before linking           #
#                               (solves -j problems)                                                                  #
# 03.13.06  2016-04-28  virrro  Introduced targets_without_dependencies to prevent useless dependency runs,           #
#                               introduced NANT_SETUP_ROOT + versioned NANT path                                      #
# 03.13.07  2016-05-04  virrro  Fixed dependency run for default build target                                         #
# 03.13.08  2016-05-24  visbwa  Added multi + cs to targets_without_dependencies                                      #
# 03.13.09  2016-07-07  visget  Support of wildcards in mak files                                                     #
# 03.13.10  2016-07-07  visbwa  Added depend to targets_without_dependencies                                          #
# 03.13.11  2016-07-08  visjhr  Use MAKE_CLEAN_PATTERN_LIST for clean target                                          #
# 03.13.12  2016-07-25  visci   Added output of resource-script to console output                                     #
# 03.13.13  2016-08-08  visget  Unavailable sources are not ignored                                                   #
# 03.13.15  2016-10-31  visfsn  Fixed m visual targets ("too many arguments") Fixed conditional linker script         #
#                               generation                                                                            #
# 03.13.16  2016-11-09  vishan  introduced new target -clean_startAppl                                                #
# 03.13.17  2016-11-21  visbwa  Added help to targets_without_dependencies                                            #
# 03.13.18  2016-11-30  virrro  Updated to NAntSupport version 02.08.00                                               #
# 03.13.19  2017-01-12  virrro  Updated to NAntSupport version 02.09.01                                               #
# 03.13.20  2017-02-07  visbwa  Added target delete_dld to delete linker script, automatically called within target   #
#                               'all', if USER_LINKER_COMMAND_FILE is not used                                        #
#           2017-02-28  virrro  Updated to NAntSupport version 02.11.latest                                           #
# 03.13.21  2017-03-27  visbwa  Added include to VISUAL_INC_LIST (VS10+12 target) Added OS_GEN7_LINK_FILES into link  #
#                               rule for better OsGen7 support (new link if files changed) Made linker-script         #
#                               deletion depending to new Makefile paramter DELETE_DLD (Brs_Template 2.01)            #
# 03.13.22  2017-05-09  visbwa  Added rebuild to targets_without_dependencies (calls "default" after, which runs dep  #
#                               later)                                                                                #
# 03.13.23  2017-05-24  visbwa  Support for A2L_AdressUpdate.bat of StartApplication UseCase XCP                      #
# 03.13.24  2017-06-14  visbwa  Deleted outdated build target visual10                                                #
# 03.13.25  2017-06-16  virrro  Updated to NAntSupport version 02.13.latest                                           #
# 03.13.26  2017-06-21  virrro  Added initial support for parallel dependencies                                       #
# 03.13.27  2017-07-12  visvnn  Deleted outdated particular support for OsekOS+ AutosarOS, replaced usage of          #
#                               ASR_MODULE_USED_LST by direct access to MODULE_USED_LST, added buildtaget             #
#                               print-%  : ; @echo $* = "$($*)", fixed ECHOESC problems within visual target          #
# 03.13.28  2017-07-25  virrro  Added NAnt-files/Gen/%.xml build.xml to targets without dependencies                  #
# 03.13.30  2017-09-22  visfsn  Reordered and commented build variable section, Added "$(ROOT)\" prefix to            #
#                               MODULE_SOURCE_LST, In Vector Make usecase, SUBDIRS contains now only subdirs in BSW   #
#                               folder (analog to ASR Make), Invented additional variables (e.g. for headers),        #
#                               Optimized/Unified visual10/visual12 target                                            #
# 03.13.31  2017-09-22  visfsn  Rollback to 3.13.28 due to problems with ACC                                          #
# 03.13.32  2017-10-05  visfsn  Added changes from 3.13.30 again, Added function safeSort to avoid issues with path   #
#                               lists containing escaped spaces                                                       #
# 03.13.33  2017-10-27  vismin  Rework of file header according to zBrs_Template@root[2.01.06]                        #
# 03.13.34  2018-01-29  visget  Removed duplicated source file occurrence in case of wildcard expansion               #
# 03.13.35  2018-01-29  visbwa  Fixed foreach-blank problems within VisualStudio target to solve exception errors     #
#######################################################################################################################

##############################################################################
# Check if versions fit together
##############################################################################

MODULE_VERSION = 3
SUB_VERSION_HISTORY = 13
NEWEST_SUB_VERSION = 13
RELEASE_VERSION    = 35

MPPD_VERSION_HISTORY = 23 24 25 26 27 28 29 30 31 32 33

ifeq ($(PLATFORM),VTT_ONLY)
  $(warning Warning: Makesupport is in VTTonly mode! Only generation of Deliverydescription is possible.)
endif

ifneq ($(SUB_VERSION), $(findstring $(SUB_VERSION),$(SUB_VERSION_HISTORY)))
  $(error MakeSupport-Subversion <$(SUB_VERSION)> is not supported. \
          Go back to Makesupport 3.12.xx or update your platform Makefile)
else
  ifneq ($(SUB_VERSION), $(NEWEST_SUB_VERSION))
    $(warning Warning: <Makefile> is not up to date.)
    $(warning Used subversion is <$(SUB_VERSION)>. \
              Newest subversion is <$(NEWEST_SUB_VERSION)>.)
  endif
endif

ifneq ($(PLATFORM),VTT_ONLY)
  ifeq ($(MPPD_VERSION),)
    $(warning Warning: Unknown Makefile.project.part.defines Version! Please update to current template.)
  else
    ifneq ($(MPPD_VERSION), $(findstring $(MPPD_VERSION),$(MPPD_VERSION_HISTORY)))
      $(error Makefile.project.part.defines Version <$(MPPD_VERSION)> is not supported!)
    endif
  endif
endif

##############################################################################
# Tool settings
##############################################################################

#-----------------------------------------------------------------------------
# Path where the Makefile can find additional executables
#-----------------------------------------------------------------------------
CMD_PATH = $(subst \,\\,$(MAKESUPPORT_DIR))/cmd

#-----------------------------------------------------------------------------
# Shell used by Makefile
#-----------------------------------------------------------------------------
SHELL = $(CMD_PATH)/sh

#-----------------------------------------------------------------------------
# $(MAKEDEPEND) defines the C-Preprocessor used for the automatic dependency
# generation.
#-----------------------------------------------------------------------------
MAKEDEPEND = $(CMD_PATH)/cpp0

#-----------------------------------------------------------------------------
# Command to copy a file or directory
#-----------------------------------------------------------------------------
CP = $(CMD_PATH)/cp -f

#-----------------------------------------------------------------------------
# Command to remove a file without user requests
#-----------------------------------------------------------------------------
RM = $(YES) n | $(CMD_PATH)/rm

#-----------------------------------------------------------------------------
# Command to remove a whole directory recursively without user requests
#-----------------------------------------------------------------------------
RRM = $(YES) n | $(CMD_PATH)/rm -r

#-----------------------------------------------------------------------------
# Command to rename ore move a file or directory
#-----------------------------------------------------------------------------
MV = $(CMD_PATH)/mv -f

#-----------------------------------------------------------------------------
# Command to print out a text to standard out
# escape sequences are suppressed
#-----------------------------------------------------------------------------
ECHO = $(CMD_PATH)/echo -E

#-----------------------------------------------------------------------------
# Command to print out a text to standard out
# escape sequences are interpreted
#-----------------------------------------------------------------------------
ECHOESC = $(CMD_PATH)/echo

#-----------------------------------------------------------------------------
# Command to create a directory
#-----------------------------------------------------------------------------
MKDIR = $(CMD_PATH)/mkdir

#-----------------------------------------------------------------------------
# Stream Editor
#-----------------------------------------------------------------------------
SED = $(CMD_PATH)/sed

#-----------------------------------------------------------------------------
# GAWK
#-----------------------------------------------------------------------------
GAWK = $(CMD_PATH)/gawk

#-----------------------------------------------------------------------------
# Tee
#-----------------------------------------------------------------------------
TEE = $(CMD_PATH)/tee -a

#-----------------------------------------------------------------------------
# Cat
#-----------------------------------------------------------------------------
CAT = $(CMD_PATH)/cat

#-----------------------------------------------------------------------------
# Yes
#-----------------------------------------------------------------------------
YES = $(CMD_PATH)/yes

#-----------------------------------------------------------------------------
# XSLT processor
#-----------------------------------------------------------------------------
XSLT = $(CMD_PATH)/xslt/XslTransCmd.exe

#-----------------------------------------------------------------------------
# XSL Sheet for releasesheet transformation
#-----------------------------------------------------------------------------
RELSHEET_XSL = $(CMD_PATH)/xslt/ReleaseSheet.xslt

#-----------------------------------------------------------------------------
# Current working dir
#-----------------------------------------------------------------------------
CURDIR = $(shell cmd /c cd)

#-----------------------------------------------------------------------------
# copy
#-----------------------------------------------------------------------------
XCOPY = xcopy /Q /Y

#-----------------------------------------------------------------------------
# Gnu Size Utility included
#-----------------------------------------------------------------------------
GSIZE = $(CMD_PATH)/size

#-----------------------------------------------------------------------------
# PC-Lint
# (configured within Makefile.analysis)
#-----------------------------------------------------------------------------
PCLINT_UNIX = $(subst \,/,$(PCLINT))
PCLINT_CMD  = $(subst \,/,$(PCLINT_FILE))


##############################################################################
# Check if necessary Variables are defined
##############################################################################

ifneq ($(PLATFORM),VTT_ONLY)
  #-----------------------------------------------------------------------------
  # $(MUSTVAR_LIST) contains all variables needed by MakeSupport
  #-----------------------------------------------------------------------------
  MUSTVAR_LIST = COMPILER_BASE \
                 COMPILER_BIN  \
                 ROOT          \
                 CC            \
                 CINC          \
                 LD            \
                 LNK_SUFFIX    \
                 BINARY_SUFFIX \
                 OBJ_SUFFIX    \
                 PROJECT_NAME  \
                 OBJ_OUTPUT    \
                 ERR_OUTPUT    \
                 OBJ_PATH      \
                 ERR_PATH      \
                 LST_PATH      \
                 LOG_PATH

  MISSING_VARS = $(filter __MISSING_VAR__%,                            \
                   $(foreach MUSTVAR,$(MUSTVAR_LIST),                  \
                     $(subst ,__MISSING_VAR__$(MUSTVAR),$($(MUSTVAR))) \
                   ) \
                 )

  MISSING_CONF_VARS = $(filter __MISSING_VAR__%,                            \
                        $(foreach MUSTVAR,$(REQUIRED_MK_CONF_VARS),         \
                          $(subst ,__MISSING_VAR__$(MUSTVAR),$($(MUSTVAR))) \
                        ) \
                      )

  ifneq ($(MISSING_CONF_VARS),)
    $(error Variable(s) $(subst __MISSING_VAR__,,$(MISSING_CONF_VARS)) are missing or not configured correctly in Makefile.config)
  endif

  ifneq ($(MISSING_VARS),)
    $(error Variable(s) $(subst __MISSING_VAR__,,$(MISSING_VARS)) are missing)
  endif

  ifeq ($(GENTOOL_DIR),)
    $(error Variable GENTOOL_DIR is not defined in _Makefile.project.part.defines)
  endif
endif

##############################################################################
# Derivative control
##############################################################################

#-----------------------------------------------------------------------------
# Retrieve CPU type (grep C_PROCESSOR_*_DERIVATIVE from $(V_CFG_LOC)\v_cfg.h)
# Only if DERIVATIVE is NOT set (oldstyle Makefile)
# AND v_cfg.h exists (V_CFG_DETECTED==1)
# AND v_cfg.h usage is NOT disabled (USE_V_CFG==1)
#-----------------------------------------------------------------------------
ifeq ($(DERIVATIVE),)

  ifeq ($(CPU_TYPE),)

    ifeq ($(V_CFG_LOC),)
      $(error V_CFG_LOC (folder of v_cfg.h file) not set within Makefile!)
    endif

    V_CFG = $(subst \,/,$(V_CFG_LOC)/v_cfg.h)

    V_CFG_DETECTED = $(shell if [ -f $(V_CFG) ]; then $(ECHO) 1; else $(ECHO) 0; fi)

    ifeq ($(USE_V_CFG),)
      ifeq ($(V_CFG_DETECTED),1)
        USE_V_CFG = 1
      else
        USE_V_CFG = 0
      endif
    endif

    ifeq ($(V_CFG_DETECTED),1)
      ifeq ($(USE_V_CFG),1)
        CPU_TYPE  = $(firstword \
                      $(shell if [ -f $(V_CFG) ] ; then \
                        $(SED) -n 's/^[ \t]*\#define[ \t]*C_PROCESSOR_\([_A-Z0-9]*\)/\1/p' $(V_CFG) | \
                        $(SED) 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'; \
                      else \
                        $(ECHO) "FILE_NOT_FOUND"; \
                      fi) \
                    NONE_FOUND)
      endif
    endif

    ifeq ($(CPU_TYPE),)
      $(error CPU type is not defined (it can be set manually in Makefile) ! \
              Supported types are: $(SUPPORTED_CPU) \
      )
    else
      ifeq ($(findstring $(CPU_TYPE),$(SUPPORTED_CPU)),)
        ifeq ($(CPU_TYPE), FILE_NOT_FOUND)
          $(error "v_cfg.h" cannot be found in directory "$(V_CFG_LOC)")
        else
          $(error CPU type ($(CPU_TYPE)) not supported by Makefile. \
                  Supported types are: $(SUPPORTED_CPU) \
          )
        endif
      endif
    endif

  else
    DERIVATIVE = $(CPU_TYPE)
  endif
endif

##############################################################################
# Default settings
##############################################################################

#Default prefix for compiler define
ifeq ($(CDEF),)
  CDEF = -D
endif

#Default path for libraries
ifeq ($(LIB_PATH),)
  LIB_PATH=lib
endif

#Default path for gendata
ifeq ($(GENDATA_DIR),)
  GENDATA_DIR  = $(shell if [ -d data ] ; then $(ECHO) "data"; else $(ECHO) "GenData"; fi)
endif

#Default common dir
ifeq ($(COMMON_DIR),)
  COMMON_DIR=BSW\_Common
endif

#Default Third Party dir
ifeq ($(GLOBAL_THIRDPARTY_DIR),)
  GLOBAL_THIRDPARTY_DIR = ..\ThirdParty
endif

#-----------------------------------------------------------------------------
# Suffix of generated Object, Error and Link Files
#-----------------------------------------------------------------------------
ifeq ($(OBJ_SUFFIX),)
  OBJ_SUFFIX=o
endif

ifeq ($(ASM_SUFFIX),)
  ASM_SUFFIX=asm
endif

ifeq ($(ERR_SUFFIX),)
  ERR_SUFFIX=err
endif

ifeq ($(LST_SUFFIX),)
  LST_SUFFIX=lst
endif

ifeq ($(LNK_SUFFIX),)
  LNK_SUFFIX=lnk
endif

ifeq ($(LIB_SUFFIX),)
  LIB_SUFFIX=lib
endif

ifeq ($(DEP_SUFFIX),)
  DEP_SUFFIX=dep
endif

#-----------------------------------------------------------------------------
# Default values for lst and error file suffix
#-----------------------------------------------------------------------------
ifeq ($(LST_SUFFIX_LIST),)
  LST_SUFFIX_LIST = lst
endif
ifeq ($(ERR_SUFFIX_LIST),)
  ERR_SUFFIX_LIST = err
endif

##############################################################################
# Construction of source list
##############################################################################

# $(MODULE_LIST) contains all modules defined in Makefile.Project.Part.Defines
MODULE_LIST += $(sort $(MODULE_LIST_PROJECT))

# $(MODULE_USED_LST) contains all activated modules in Makefile.Project.Part.Defines
MODULE_USED_LST := $(filter-out 0, \
                    $(foreach MODULE,$(MODULE_LIST), \
                      $(subst 1,$(MODULE),$($(MODULE)_USED)) \
                    ) \
                  )

#-------------------------------
# ASR SPECIFIC BUILD DEFINITIONS
#-------------------------------
ifeq ($(USE_AUTOSAR_MAKE),1)

  # Variable definition for AUTOSAR files
  OBJ_FILE_SUFFIX = $(OBJ_SUFFIX)
  OBJ_OUTPUT_PATH = $(OBJ_PATH)

  #----------------
  #CALL FUNCTIONS
  #----------------

  asrDir  = $(firstword $(filter-out ���,$(subst \ , ,$($(1)_PATH)  ���)))
  asrName = $(notdir $(call asrDir,$(1)))

  #Returns static source files for given module, based on component *.mak files
  #Add ??? to avoid multiple findings
  #findstring ???nm/ in ???cnm/cnm.c ???nm/nm.c
  compSources = $(strip  $(foreach SOURCE,$(MODULE_SOURCE_LST_LC), \
                  $(if $(findstring $(call _toLower,???\$(call asrDir,$(1)))\,???$(SOURCE)),$(SOURCE)) \
                  ))

  #  libObjects = $(addprefix $(OBJ_PATH)/,$(addsuffix .$(OBJ_SUFFIX),$(basename $(notdir $($(1)_FILES)))))
  libObjects = $(addprefix $(OBJ_PATH)/,$(addsuffix .$(OBJ_SUFFIX),$(basename $(notdir $(wildcard $(subst \,/,$(addprefix $(ROOT)\$(GLOBAL_COMP_DIR)\,$($(1)_FILES))))))))

  #--------------------------
  #ASR COMPONENT MAKE INCLUDE
  #--------------------------

  ifneq ($(MODULE_USED_LST),)
    include $(foreach MODULE,$(MODULE_USED_LST),$(ROOT)\$(call asrDir,$(MODULE))\mak\$(call asrName,$(MODULE))_rules.mak \
                                                $(ROOT)\$(call asrDir,$(MODULE))\mak\$(call asrName,$(MODULE))_defs.mak  \
                                                $(ROOT)\$(call asrDir,$(MODULE))\mak\$(call asrName,$(MODULE))_check.mak)
  endif

  # Consistancy Check of ASR Makefiles
  $(foreach LIB,$(LIBRARIES_TO_BUILD), \
    $(if $($(LIB)_FILES),,$(error Library $(LIB) has no corrospending $(LIB)_FILES definition)) \
  )

  #-----------------------
  #BUILD VARIABLES (FILES)
  #-----------------------
 
  # Consistancy Check of MPPD
  $(foreach MODULE,$(MODULE_USED_LST), \
    $(if $(call asrDir,$(MODULE)),, \
      $(error Error: Module $(MODULE) is not in Makefile.project.part.defines with $(MODULE)_PATH) \
    ) \
  )

  #List of all active static BSW source files, taken from the component *.mak files
  #$(ROOT) and $(GLOBAL_COMP_DIR) are added as prefix
  #Other static files (e.g. MCAL) might be included
  #No wildcard expansion yet
  MODULE_SOURCE_LST_RAW = $(addprefix $(if $(GLOBAL_COMP_DIR),$(ROOT)\$(GLOBAL_COMP_DIR),$(ROOT)),$(addprefix \,$(CC_FILES_TO_BUILD)))

  #$(MODULE_SOURCE_LST_RAW) with expanded wildcards (*) 
  MODULE_SOURCE_LST     = $(subst /,\,$(wildcard $(subst \,/,$(call safeSort,$(MODULE_SOURCE_LST_RAW)))))

  #$(MODULE_SOURCE_LST) in lower case
  MODULE_SOURCE_LST_LC  = $(call _toLower,$(MODULE_SOURCE_LST))

  #List of all active generated BSW source files, taken from the component *.mak files
  #No wildcard expansion yet
  MODULE_DATA_LST_RAW   = $(filter-out %.$(ASM_SUFFIX),$(GENERATED_SOURCE_FILES))

  #$(MODULE_DATA_LST_RAW) with expanded wildcards (*) 
  MODULE_DATA_LST       = $(subst /,\,$(wildcard $(subst \,/,$(MODULE_DATA_LST_RAW))))

  MODULE_COMMON_LST     = $(COMMON_SOURCE_FILES)

  ASM_SOURCES          += $(foreach ASM,$(ASM_FILES_TO_BUILD),$(subst \,/,$(ROOT)/$(GLOBAL_COMP_DIR)/$(ASM))) $(filter %.$(ASM_SUFFIX),$(GENERATED_SOURCE_FILES) ) $(ASM_GENERATED_SOURCE_FILES)

  COMP_MAKE_INC        += $(foreach IPATH,$(CC_INCLUDE_PATH),$(ROOT)\$(GLOBAL_COMP_DIR)\$(IPATH))
  COMP_MAKE_INC        += $(foreach IPATH,$(CPP_INCLUDE_PATH),$(ROOT)\$(GLOBAL_COMP_DIR)\$(IPATH))
  COMP_MAKE_INC        += $(foreach IPATH,$(ASM_INCLUDE_PATH),$(ROOT)\$(GLOBAL_COMP_DIR)\$(IPATH))

  ADDITONAL_LIBRARIES  += $(foreach LIB,$(LIBRARIES_LINK_ONLY),$(ROOT)\$(GLOBAL_COMP_DIR)\$(LIB))
  ADDITIONAL_OBJECTS   += $(foreach OBJ,$(OBJECTS_LINK_ONLY),$(ROOT)\$(GLOBAL_COMP_DIR)\$(OBJ))

  #List of all static BSW subfolders, derived from MODULE_USED_LST and the *_PATH definitions in Makefile.Project.Part.Defines
  SUBDIRS               = $(foreach MODULE,$(MODULE_USED_LST),$(ROOT)\$($(MODULE)_PATH))

  SUBDIRS_UNIX          = $(subst ???,\ ,$(subst \,/,$(subst \ ,???,$(SUBDIRS))))
  
#  lib$(PROJECT_NAME)_FILES =  $(foreach MODULE,$(sort $(MODULE_SOURCE_LST)), \
#                                $(addprefix $(OBJ_PATH)/,$(addsuffix .$(OBJ_SUFFIX),$(basename $(notdir $(MODULE))))) \
#                              )
  lib$(PROJECT_NAME)_FILES = $(foreach MODULE,$(wildcard $(subst \,/,$(call safeSort,$(MODULE_SOURCE_LST)))),$(subst $(ROOT)\$(GLOBAL_COMP_DIR)\,,$(subst /,\,$(MODULE))))

#------------------------------------------------
# VECTOR (CBD/FBL/OS) SPECIFIC BUILD DEFINITIONS
#------------------------------------------------
else
  #----------------
  #CALL FUNCTIONS
  #----------------

  compSources = $($(1)_SOURCES)

  libObjects = $(addprefix $(OBJ_PATH)/,$(addsuffix .$(OBJ_SUFFIX),$(sort $(basename $(notdir $(call compSources,$(subst lib,,$(1))))))))

  #------------------------
  #BUILD VARIABLES (FILES)
  #------------------------

  MODULE_USED_STATIC_LST := $(filter-out 0, \
                               $(foreach MODULE,$(MODULE_LIST), \
                                   $(subst 1,$(if $($(MODULE)_SOURCES),$(MODULE),0),$($(MODULE)_USED)) \
                               ) \
                           )

  LIBRARIES_TO_BUILD = $(foreach MODULE,$(MODULE_USED_STATIC_LST), lib$(MODULE))

  #List of all active static BSW source files, taken Makefile.Project.Part.Defines
  #$(ROOT) is added as prefix
  #No wildcard expansion yet
  MODULE_SOURCE_LST_RAW := $(addprefix $(ROOT)\, \
                             $(filter-out 0, \
                               $(foreach MODULE,$(MODULE_LIST), \
                                   $(subst 1,$($(MODULE)_SOURCES),$($(MODULE)_USED)) \
                               ) \
                             ) \
                           )

  #$(MODULE_SOURCE_LST_RAW) with expanded wildcards (*) 
  MODULE_SOURCE_LST = $(subst /,\,$(wildcard $(subst \,/,$(MODULE_SOURCE_LST_RAW))))

  #List of all active generated BSW source files, taken Makefile.Project.Part.Defines
  #No wildcard expansion yet
  MODULE_DATA_LST_RAW := $(filter-out 0, \
                           $(foreach MODULE,$(MODULE_LIST), \
                             $(subst 1,$($(MODULE)_DATA),$($(MODULE)_USED)) \
                           ) \
                         )

  #$(MODULE_DATA_LST_RAW) with expanded wildcards (*) 
  MODULE_DATA_LST = $(subst /,\,$(wildcard $(subst \,/,$(MODULE_DATA_LST_RAW))))

  MODULE_COMMON_LST := $(filter-out 0, \
                         $(foreach MODULE,$(MODULE_LIST), \
                           $(subst 1,$($(MODULE)_COMMON),$($(MODULE)_USED)) \
                         ) \
                       )
  #List of all static BSW subfolders, derived from MODULE_DATA_LST
  SUBDIRS = $(subst ???,\ ,$(sort $(foreach ENTRY,$(dir $(subst \ ,???,$(MODULE_SOURCE_LST))),$(patsubst %\,%,$(ENTRY)))))

  SUBDIRS_UNIX = $(subst ???,\ ,$(subst \,/,$(subst \ ,???,$(SUBDIRS))))

endif

#-------------------------------
# GENERIC BUILD DEFINITIONS
#-------------------------------

#----------------
#CALL FUNCTIONS
#----------------

# Returns all header files (with path) in a given directory
# Prerequisites: Syntax has to start from Appl dir
# Example: $(call incHeaders,Include) will return all header files in "Include" folder
incHeaders = $(subst /,\,$(wildcard $(subst \,/,$(1)\*.h)))

# Performs sorting of a given (path) list without trouble of escaped space characters ("\ ")
# "\ " is temporarily replaced by ??? for sorting
safeSort = $(subst ???,\ ,$(sort $(subst \ ,???,$(1))))

#-------------------------
#BUILD VARIABLES (FILES)
#-------------------------

# All header files in $(COMP_DIR) folder (e.g. external\BSW)
# ASR only: Other static files (e.g. MCAL) might be included
# Syntax: Starting from Appl dir, with backslashes
ifneq ($(SUPPRESS_COMP_MAKE_INCLUDES),1)
MODULE_HEADER_LST = $(foreach DIR,$(call safeSort,$(SUBDIRS) $(COMMON_INC) $(COMP_MAKE_INC)),$(subst /,\,$(wildcard $(subst \,/,$(DIR)\*.h))))
else
MODULE_HEADER_LST = $(foreach DIR,$(SUBDIRS) $(COMMON_INC) ,$(subst /,\,$(wildcard $(subst \,/,$(DIR)\*.h))))
endif

# All source files in ThirdParty folder (e.g. MCAL)
# Syntax: Starting from Appl dir, with backslashes
THIRD_PARTY_SOURCES := $(filter $(ROOT)\$(if $(GLOBAL_COMP_DIR),$(GLOBAL_COMP_DIR)\,)$(GLOBAL_THIRDPARTY_DIR)%,$(MODULE_SOURCE_LST))

# All header files in ThirdParty folder (e.g. MCAL)
# Syntax: Starting from Appl dir, with backslashes
# Constraint: Works only for ASR Make
THIRD_PARTY_HEADERS := $(filter $(ROOT)\$(if $(GLOBAL_COMP_DIR),$(GLOBAL_COMP_DIR)\,)$(GLOBAL_THIRDPARTY_DIR)%,$(MODULE_HEADER_LST))

# All generated module source files
# Syntax: Starting from Appl dir, with backslashes
GEN_SOURCES = $(MODULE_DATA_LST)

# All generated module header files in Gendata folder
# Syntax: Starting from Appl dir, with backslashes
GEN_HEADERS = $(foreach INCDIR,$(filter $(GENDATA_DIR)%,$(INC_LIST)),$(call incHeaders,$(INCDIR)))

# All used source files from Compiler folder
# Syntax: Starting from Appl dir, with backslashes
COMPILER_SOURCES = $(filter $(subst /,\,$(COMPILER_BASE))%,$(subst /,\,$(SOURCES)))

# All used header files from Compiler folder
# Syntax: Starting from Appl dir, with backslashes
COMPILER_HEADERS := $(foreach DIR, $(COMPILER_INC),$(call incHeaders,$(DIR)))


# List of all sources used (and linked together!) in this project
# Variable $(SOURCES) is used for target compilation
# Wildcard expansion is already performed for MODULE_SOURCE_LIST/MODULE_DATA_LIST
SOURCES = $(call safeSort,$(filter-out $(SOURCES_IN_LIBS),$(MODULE_SOURCE_LST)) \
          $(MODULE_DATA_LST) \
          $(APP_SOURCE_LST)  \
          $(DATA_SOURCE_LST) \
          $(MODULE_COMMON_LST)\
          )

SOURCES_UNIX = $(subst ???,\ ,$(subst \,/,$(subst \ ,???,$(SOURCES))))

#SOURCES := $(foreach SRC,$(SOURCES),$(if $(findstring *,$(SRC)),$(subst /,\,$(wildcard $(subst \,/,$(SRC)))),$(SRC)))


SOURCES_IN_LIBS =  $(foreach LIB,$(LIBRARIES_TO_LINK),\
                     $(foreach FILE,$($(LIB)_FILES),$(ROOT)\$(GLOBAL_COMP_DIR)\$(FILE)) \
                   )

#List of all sources that shall be compiled to libraries
#No wildcard expansion yet
LIB_SOURCES_RAW = $(foreach LIB, $(LIBRARIES_TO_BUILD),$(foreach LIBSRC,$($(LIB)_FILES),$(ROOT)\$(GLOBAL_COMP_DIR)\$(LIBSRC)))

#List of all sources that shall be compiled to libraries with wildcard expansion
LIB_SOURCES = $(subst /,\,$(wildcard $(subst \,/,$(LIB_SOURCES_RAW))))

LIB_SOURCES_UNIX = $(subst ???,\ ,$(subst \,/,$(subst \ ,???,$(LIB_SOURCES))))

#Unix syntax (with "/" instead of "\")
SOURCES_APPL_UNIX = $(subst ???,\ ,$(subst \,/,$(subst \ ,???,$(APP_SOURCE_LST))))

#List of all headers in all used include folders
HEADERS = $(subst /,\,$(foreach INC,$(call safeSort,$(subst //,/,$(INC_LIST))),$(wildcard $(INC)/*.h)))

#-------------------------
#BUILD VARIABLES (INCLUDES)
#-------------------------

COMMON_INC = $(foreach dir, $(COMMON_DIR), $(ROOT)\$(dir))
FBLCAN_INC = $(if $(findstring 1,$(FBLCAN_USED) $(CANFBL_USED)),$(ROOT)\drvflash $(ROOT)\BSW\Flash)

# Unsorted list of all include directories
# Syntax: Starting from Appl dir, with backslashes
INC_LIST_RAW = $(COMMON_INC)   \
               $(FBLCAN_INC)   \
               $(GENDATA_DIR)  \
               $(SUBDIRS)      \
               $(COMPILER_INC) \
               $(ADDITIONAL_INCLUDES)

ifneq ($(SUPPRESS_COMP_MAKE_INCLUDES),1)
  INC_LIST_RAW += $(COMP_MAKE_INC)
endif

# Sorted list of all include directories
# Syntax: Starting from Appl dir, with backslashes
#INC_LIST = $(sort $(subst \\,\,$(subst /,\,$(INC_LIST_RAW))))
#INC_LIST = $(subst \\,\,$(subst /,\,$(INC_LIST_RAW)))
#INC_LIST = $(sort $(INC_LIST_RAW))		
#INC_LIST = $(subst ???,\ ,$(sort $(subst \\,\,$(subst /,\,$(subst \ ,???,$(INC_LIST_RAW))))))
INC_LIST = $(call safeSort,$(subst \\,\,$(subst /,\,$(INC_LIST_RAW))))

#Includes for preprocessor
GCCINC_LIST = $(subst \,/,$(subst \ ,???, $(INC_LIST)))

GCCINCLUDES = $(subst ???,\ ,$(addprefix -I, $(sort $(call toLower,GCCINC_LIST))))

#Includes for compiler (with prefix)
INCLUDES_UNIX = $(subst ???,\ ,$(subst -I,$(CINC),$(subst \ ,???,$(GCCINCLUDES))))
INCLUDES  = $(subst /,\,$(INCLUDES_UNIX))

CC_U     = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(CC))))
LD_U     = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(LD))))
AS_U     = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(AS))))
LB_U     = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(LB))))
EXT_T1_U = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(EXT_T1))))
EXT_T2_U = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(EXT_T2))))

ifeq ($(CC_ENV_U),)
  CC_ENV_U     = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(CC_ENV))))
endif
ifeq ($(LD_ENV_U),)
  LD_ENV_U     = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(LD_ENV))))
endif
ifeq ($(AS_ENV_U),)
  AS_ENV_U     = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(AS_ENV))))
endif
ifeq ($(LB_ENV_U),)
  LB_ENV_U     = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(LB_ENV))))
endif
ifeq ($(EXT_T1_ENV_U),)
  EXT_T1_ENV_U = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(EXT_T1_ENV))))
endif
ifeq ($(EXT_T2_ENV_U),)
  EXT_T2_ENV_U = $(subst ?????,\ ,$(subst \,/,$(subst \ ,?????,$(EXT_T2_ENV))))
endif

#-------------------------
#BUILD VARIABLES (OBJECTS)
#-------------------------
#-----------------------------------------------------------------------------
# $(OBJECTS) represents the objectfiles which will be linked together
# This var is generated by replacing the suffix of the files defined in
# $(SOURCES) (Makefile.project.part.defines) by .$(OBJ_SUFFIX)
#-----------------------------------------------------------------------------
ifeq ($(USE_AUTOSAR_MAKE),1)
  ADDITONAL_LIBRARIES = $(foreach LIB,$(LIBRARIES_TO_LINK), $(call libtarget,$(LIB)))
endif
BUILD_OBJECTS = $(sort $(strip $(subst /,\,$(addprefix $(OBJ_PATH)/, \
                  $(addsuffix .$(OBJ_SUFFIX),$(basename $(notdir $(SOURCES) $(ASM_SOURCES)))) \
                ))))

OBJECTS = $(sort $(strip $(subst /,\,$(BUILD_OBJECTS) $(ADDITIONAL_OBJECTS) $(ADDITONAL_LIBRARIES) )))

OBJECTS_U       = $(subst \,/,$(OBJECTS))
BUILD_OBJECTS_U = $(subst \,/,$(BUILD_OBJECTS))
BUILD_LIBS      = $(addprefix $(LIB_PATH)/,$(addsuffix .$(LIB_SUFFIX), $(sort $(strip $(LIBRARIES_TO_BUILD)))))
BUILD_LIBS      += $(LIB_PATH)/lib$(PROJECT_NAME).$(LIB_SUFFIX)
BUILD_LIBS_U    = $(subst /,\,$(BUILD_LIBS))

##############################################################################
# Patternlist definitions
##############################################################################

#-----------------------------------------------------------------------------
# create subdirs used for err/obj/lst files
##-----------------------------------------------------------------------------

DIR_LIST = $(OBJ_PATH) $(ERR_PATH) $(LST_PATH) $(LOG_PATH) $(LIB_PATH)

GENDATA_DIR_U = $(subst \,/,$(GENDATA_DIR))

ifeq ($(BRSVINFO_USED),1)
  PREDEP += $(GENDATA_DIR_U)/BrsVInfo.h
endif

LINKER_COMMAND_FILE = $(if $(USER_LINKER_COMMAND_FILE),$(USER_LINKER_COMMAND_FILE),$(PROJECT_NAME).$(LNK_SUFFIX))

#-----------------------------------------------------------------------------
# all files contained in $(CLEANDIRS) matching $(DEL_PATTERN_LIST) are deleted
# by clean target
#-----------------------------------------------------------------------------
DEL_PATTERN_LIST += $(PROJECT_NAME).$(LNK_SUFFIX) \
                    $(PROJECT_NAME).dep           \
                    $(PROJECT_NAME).hex           \
                    $(PROJECT_NAME).ilk           \
                    $(OBJ_PATH)\*.*               \
                    $(ERR_PATH)\*.*               \
                    $(LST_PATH)\*.*               \
                    $(LIB_PATH)\*.*               \
                    $(LOG_PATH)\*.*               \
                    $(MAKE_CLEAN_PATTERN_LIST)

#-----------------------------------------------------------------------------
# all files contained in $(CLEANDIRS) matching $(DEL_PATTERN_LIST) are deleted
# by reinl target
#-----------------------------------------------------------------------------
REINL_PATTERN_LIST += $(PROJECT_NAME).$(LNK_SUFFIX) \
                      $(PROJECT_NAME).dep           \
                      $(PROJECT_NAME).hex           \
                      $(PROJECT_NAME).ilk           \
                      $(OBJ_PATH)\*.*               \
                      $(ERR_PATH)\*.*               \
                      $(LST_PATH)\*.*               \
                      $(LIB_PATH)\*.*               \
                      $(LOG_PATH)\*.*               \
                      $(GENDATA_DIR)\..\dep\*.*     \
                      $(MAKE_CLEAN_PATTERN_LIST)

DEL_PATTERN_LIST_UNIX = $(subst \,/,$(DEL_PATTERN_LIST))

CLEANDIRS             = . $(SUBDIRS) $(INCDIR_LIST)
CLEANDIRS_UNIX        = $(subst ???,\ ,$(subst \,/,$(subst \ ,???,$(CLEANDIRS))))
DIST_CLEAN_LIST  = $(sort $(subst \,/,          \
                     $(DIST_CLEAN_PATTERN_LIST) \
                     ~vssc                      \
                     vssver.scc                 \
                     *~                         \
                     *.*~                       \
                     *.~*                       \
                     *.bak                      \
                     *.log                      \
                     $(GENDATA_DIR)\*.txt       \
                     $(ERR_LIST_WOP)            \
                     $(PROJECT_NAME).dep        \
                     $(PROJECT_NAME).dsw        \
                     $(PROJECT_NAME).dsp        \
                     $(PROJECT_NAME).sln        \
                     $(PROJECT_NAME).vcproj     \
                     $(PROJECT_NAME).suo        \
                     $(PROJECT_NAME).ncb        \
                     $(PROJECT_NAME).opt        \
                     $(PROJECT_NAME).plg        \
                     $(PROJECT_NAME).doc.cfg    \
                     $(GENDATA_DIR)\BrsVInfo.h  \
                   ))

REINL_CLEAN_LIST  = $(sort $(subst \,/,              \
                      ~vssc                          \
                      vssver.scc                     \
                      *~                             \
                      *.*~                           \
                      *.~*                           \
                      *.bak                          \
                      *.log                          \
                      $(GENDATA_DIR)\*.txt           \
                      $(ERR_LIST_WOP)                \
                      $(PROJECT_NAME).dep            \
                      $(PROJECT_NAME).dsw            \
                      $(PROJECT_NAME).dsp            \
                      $(PROJECT_NAME).sln            \
                      $(PROJECT_NAME).vcproj         \
                      $(PROJECT_NAME).suo            \
                      $(PROJECT_NAME).ncb            \
                      $(PROJECT_NAME).opt            \
                      $(PROJECT_NAME).plg            \
                      $(PROJECT_NAME).doc.cfg        \
                      $(GENDATA_DIR)\BrsVInfo.h      \
                      $(GENDATA_DIR)\..\..\.cproject \
                      $(GENDATA_DIR)\..\..\.project  \
                   ))

#-----------------------------------------------------------------------------
# Preprocessor settings
#-----------------------------------------------------------------------------
CPPFLAGS     = -M
STRICT_C_OFF = 1
ifeq ($(STRICT_C_OFF),)
  CPPFLAGS += -std=c89  \
              -pedantic \
              -Wall
else
  CPPFLAGS += -lang-c++ \
              -w
endif

CPPFLAGS    += $(foreach DEF,$(DEP_DEFINES),-D$(DEF))

#-----------------------------------------------------------------------------
# Function to set all characters in list to upper case
# the parameter is the name of the list
#-----------------------------------------------------------------------------
toUpper = $(subst ~~???~~,\,$(shell $(ECHO) $(subst \,~~???~~,$($(1))) \
              | $(SED) 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
           ))

#-----------------------------------------------------------------------------
# Function to set all characters in list to lower case
# the parameter is the name of the list
#-----------------------------------------------------------------------------
toLower = $(subst ~~???~~,\,$(shell $(ECHO) $(subst \,~~???~~,$($(1))) \
              | $(SED) 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
           ))

#-----------------------------------------------------------------------------
# Function to set all characters in list to upper case
# the parameter is the list
#-----------------------------------------------------------------------------
_toUpper = $(subst ~~???~~,\,$(shell $(ECHO) $(subst \,~~???~~,$(1)) \
              | $(SED) 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
           ))

#-----------------------------------------------------------------------------
# Function to set all characters in list to lower case
# the parameter is the list
#-----------------------------------------------------------------------------
_toLower = $(subst ~~???~~,\,$(shell $(ECHO) $(subst \,~~???~~,$(1)) \
              | $(SED) 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
           ))

#-----------------------------------------------------------------------------
# Function to perform a xcopy which accepts normal slashes
#-----------------------------------------------------------------------------
_xcopy = $(XCOPY) $(subst /,\\,$(subst \,\\,$(1))) $(subst /,\\,$(subst \,\\,$(2))) 1>/dev/null;

#-----------------------------------------------------------------------------
# Function to generate a separated List
# First parameter is the name!!! of list, second is the name!! of the separator
#-----------------------------------------------------------------------------
_EMPTY      :=
_SPACE      := $(_EMPTY) $(_EMPTY)
_SEMI_COLON  = ;
_COLON       = :
_COMMA       = ,
_OPEN_PAREN  = (
_CLOSE_PAREN = )
_DQUOTE      = "
SEPLIST_SPACE =????? #

separatedList = $(strip $(subst $(SEPLIST_SPACE),,                             \
                    $(filter-out $(word $(words $($(1))),$($(1)))$($(2))?????, \
                         $(addsuffix $($(2))?????,$($(1)))                     \
                     ) $(word $(words $($(1))),$($(1)))                        \
                 ))

#-----------------------------------------------------------------------------
# Function to generate a separated List
# First parameter is the list, second is the name!! of the separator
#-----------------------------------------------------------------------------
_separatedList = $(strip $(subst $(SEPLIST_SPACE),,                      \
                    $(filter-out $(word $(words $(1)),$(1))$($(2))?????, \
                         $(addsuffix $($(2))?????,$(1))                  \
                     ) $(word $(words $(1)),$(1))                        \
                 ))

#-----------------------------------------------------------------------------
# Function to get the index of an entry in a given list
# First parameter is the entry to be searched, second is the list
#-----------------------------------------------------------------------------
NUMBER_LIST =  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20 \
              21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40 \
              41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60 \
              61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80 \
              81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 \
             101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 \
             121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 \
             141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 \
             161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 \
             181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 \
             201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 \
             221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 \
             241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 \
             261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 \
             281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 \
             301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 \
             321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 \
             341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 \
             361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 \
             381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 \
             401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 \
             421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 \
             441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 \
             461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 \
             481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 \
             501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 \
             521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 \
             541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 \
             561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 \
             581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 \
             601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 \
             621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 \
             641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 \
             661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 \
             681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 \
             701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 \
             721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 \
             741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 \
             761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 \
             781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 \
             801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 \
             821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 \
             841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 \
             861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 \
             881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 500 \
             901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 \
             921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 \
             941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 \
             961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 \
             981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000

index  = $(patsubst %-***-$(1),%,$(filter %-***-$(1),$(join $(addsuffix -***-,$(NUMBER_LIST)),$(2))))
index0 = $(patsubst %-***-$(1),%,$(filter %-***-$(1),$(join $(addsuffix -***-,0 $(NUMBER_LIST)),$(2))))

#-----------------------------------------------------------------------------
# Function to patch lists (all entries are replaced)
# - First parameter is the name of the list which should be patched
# - Second parameter is the name of the list which contains the patterns which
#   should be patched
# - Third parameter is the Prefix of the variables which contain the
#   replacements for the patterns
# E.g:
#   PATCHLIST = this is a list
#   PATTERNS  = this a
#   REPL_this = THIS
#   REPL_a    = A
#   PATCHEDLIST = $(call patchList,PATCHLIST,PATTERNS,REPL_)
#
#   After the last assignment $(PATCHEDLIST) contains: THIS is A list
#-----------------------------------------------------------------------------
patchList = $(shell $(ECHO) $($(1)) \
                | $(SED) $(foreach ENTRY,$(strip $($(2))),-e s/$(ENTRY)/$($(3)$(ENTRY)))/g) \
             )

#-----------------------------------------------------------------------------
# Function to patch lists (all entries are replaced)
# - First parameter is the name of the file which should be patched
# - Second parameter is the name of the file for the results
# - Third parameter is the name of the list which contains the patterns which
#   should be patched
# - Fourth parameter is the Prefix of the variables which contain the
#   replacements for the patterns
# E.g:
#   PATCHLIST = this is a list
#   PATTERNS  = this a
#   REPL_this = THIS
#   REPL_a    = A
#   PATCHEDLIST = $(call patchList,PATCHLIST,PATTERNS,REPL_)
#
#   After the last assignment $(PATCHEDLIST) contains: THIS is A list
#-----------------------------------------------------------------------------
patchFile = $(shell $(SED) $(foreach ENTRY,$(strip $($(3))),-e s/$(ENTRY)/$($(4)$(ENTRY))/g) $(subst \,/,$(1) > $(2)))

#-----------------------------------------------------------------------------
# Function returns number of characters in parameter
#-----------------------------------------------------------------------------
countChars = $(shell firstString="$(1)"; $(ECHO) $${\#firstString} )

#-----------------------------------------------------------------------------
# Function to overwrite parts of a string by another string
# - First parameter is the string to be overwritten
# - Second parameter is the string which overwrites the first
#-----------------------------------------------------------------------------
overwriteString = $(shell                                       \
                    frstString="$(1)";                          \
                    scndString="$(2)";                          \
                    $(ECHO) $${scndString:$$[$${\#frstString}]} \
                   )

##############################################################################
# FLAG compilation
##############################################################################
ifneq ($(PLATFORM),VTT_ONLY)
  ASFLAGS += $(ASFLAGS_VECTOR_MAKESUPPORT)
  ifeq ($(ASFLAGS_SELECTOR), VECTOR)
    ASFLAGS += $(ASFLAGS_VECTOR_OPTIONS)
  else
    ifeq ($(ASFLAGS_SELECTOR), CUSTOMER)
      ASFLAGS += $(ASFLAGS_CUSTOMER_OPTIONS)
    else
      $(error "ASFLAGS_SELECTOR" within Makefile not set. Set to "VECTOR" or "CUSTOMER".)
    endif
  endif
  
  CFLAGS += $(CFLAGS_VECTOR_MAKESUPPORT)
  ifeq ($(CFLAGS_SELECTOR), VECTOR)
    CFLAGS += $(CFLAGS_VECTOR_OPTIONS)
  else
    ifeq ($(CFLAGS_SELECTOR), CUSTOMER)
      CFLAGS += $(CFLAGS_CUSTOMER_OPTIONS)
    else
      $(error "CFLAGS_SELECTOR" within Makefile not set. Set to "VECTOR" or "CUSTOMER".)
    endif
  endif
  
  LDFLAGS += $(LDFLAGS_VECTOR_MAKESUPPORT)
  ifeq ($(LDFLAGS_SELECTOR), VECTOR)
    LDFLAGS += $(LDFLAGS_VECTOR_OPTIONS)
  else
    ifeq ($(LDFLAGS_SELECTOR), CUSTOMER)
      LDFLAGS += $(LDFLAGS_CUSTOMER_OPTIONS)
    else
      $(error "LDFLAGS_SELECTOR" within Makefile not set. Set to "VECTOR" or "CUSTOMER".)
    endif
  endif
endif

##############################################################################
# Rule definitions
##############################################################################

#-----------------------------------------------------------------------------
#$(COMPILE_RULE) implements the Compile rule %.$(OBJ_SUFFIX): %.c. This
#define can be overriden in the project specific Makefile Example:
#override define COMPILE_RULE project specific rule endif
#-----------------------------------------------------------------------------
define COMPILE_RULE
  if [ -n "$(MKVERBOSE)" ] ; then \
    $(ECHO) "    $(CC) $(filter-out $(FILTER_$(call _toUpper,$*)),$(CFLAGS)) $(CFLAGS_$(call _toUpper,$*)) $(INCLUDES_UNIX) $< $(REDIRECT_OUTPUT)"; \
  fi; \
  $(subst \,/,$(CC_ENV) $(CC) $(filter-out $(FILTER_$(call _toUpper,$*)),$(CFLAGS)) $(CFLAGS_$(call _toUpper,$*))) $(INCLUDES_UNIX) $< $(REDIRECT_OUTPUT);
endef

#-----------------------------------------------------------------------------
#$(ASSEMBLE_RULE) implements the assemble rule %.$(OBJ_SUFFIX): %.asm. This
#define can be overriden in the project specific Makefile Example:
#override define ASSEMBLE_RULE project specific rule endif
#-----------------------------------------------------------------------------
define ASSEMBLE_RULE
  if [ -n "$(MKVERBOSE)" ] ; then \
    $(ECHO) "    $(AS) $(ASFLAGS) $(subst /,\,$<) $(REDIRECT_OUTPUT)"; \
  fi; \
  $(subst \,/,$(AS_ENV) $(AS) $(ASFLAGS)) $< $(REDIRECT_OUTPUT);
endef

#-----------------------------------------------------------------------------
# $(LINK_RULE) implements the Linking rule
# this define can be overriden in the project specific Makefile
# Example:
#     override define LINK_RULE project specific rule endif
#-----------------------------------------------------------------------------
define LINK_RULE
  if [ -n "$(MKVERBOSE)" ] ; then \
    $(ECHO) "    $(LD) $(LDFLAGS) $(LINKER_COMMAND_FILE) $(REDIRECT_OUTPUT)"; \
  fi; \
  $(subst \,/,$(LD_ENV) $(LD) $(LDFLAGS)) $(LINKER_COMMAND_FILE) $(REDIRECT_OUTPUT);
endef

#-----------------------------------------------------------------------------
# $(LIB_RULE) implements the library generation rule
# this define can be overriden in the project specific Makefile
# Example:
#     override define LIB_RULE project specific rule endif
#-----------------------------------------------------------------------------
define LIB_RULE
  if [ -n "$(MKVERBOSE)" ] ; then \
    $(ECHO) "    $(LB) $(LBFLAGS) $^ $(REDIRECT_OUTPUT)"; \
  fi; \
  $(subst \,/,$(LB_ENV) $(LB) $(LBFLAGS) $^ ) $(REDIRECT_OUTPUT);
endef

#-----------------------------------------------------------------------------
# If a decoder $(DEC) ("lstfile generator") is specified in the project
# specific Makefile it will be called after compilation
# overriding is possible
#-----------------------------------------------------------------------------
ifdef DEC
  define DECODE_RULE
    $(ECHO) "Generating lst files: $<"; \
    if [ -n "$(MKVERBOSE)" ] ; then \
      $(ECHO) "    $(DEC) $(DECFLAGS)"; \
    fi; \
    $(DEC) $(DECFLAGS);
  endef
else
  define DECODE_RULE
    $(ECHO) -n;
  endef
endif

ifeq ($(OBJ_OUTPUT),MOVE)
  #-------------------------------------------------------------------------
  # $(MOVE_OBJECT_RULE) moves generated .$(OBJ_SUFFIX) files to a specific
  # output dir. If the variable $(OBJ_OUTPUT) is set to MOVE in the
  # Makefile, this rule provides automatic movement of the generated object
  # file to the $(OBJ_PATH)
  #-------------------------------------------------------------------------
  define MOVE_OBJECT_RULE
    $(ECHO) "Moving object file: $*.$(OBJ_SUFFIX) -> $(OBJ_PATH)/$*.$(OBJ_SUFFIX)"; \
    if [ -f $*.$(OBJ_SUFFIX) ]; then $(MV) $*.$(OBJ_SUFFIX) $(OBJ_PATH)/$*.$(OBJ_SUFFIX); fi; \
    if [ -f $(<D)/$*.$(OBJ_SUFFIX) ]; then $(MV) $(<D)/$*.$(OBJ_SUFFIX) $(OBJ_PATH)/$*.$(OBJ_SUFFIX); fi;
  endef
else
  define MOVE_OBJECT_RULE
    $(ECHO) -n;
  endef
  ifneq ($(OBJ_OUTPUT),FLAGS)
    $(error Variable OBJ_OUTPUT in <Makefile> is not set correctly)
  endif
endif

ifeq ($(LIB_OUTPUT),)
    LIB_OUTPUT = $(OBJ_OUTPUT)
endif

ifeq ($(LIB_OUTPUT),MOVE)
  #-------------------------------------------------------------------------
  # $(MOVE_LIB_RULE) moves generated .$(LIB_SUFFIX) files to a specific
  # output dir. If the variable $(LIB_OUTPUT) is set to MOVE in the
  # Makefile, this rule provides automatic movement of the generated object
  # file to the $(LIB_PATH)
  #-------------------------------------------------------------------------
  define MOVE_LIB_RULE
    $(ECHO) "Moving library file: $*.$(LIB_SUFFIX) -> $(LIB_PATH)/$*.$(LIB_SUFFIX)"; \
    if [ -f $*.$(LIB_SUFFIX) ]; then $(MV) $*.$(LIB_SUFFIX) $(LIB_PATH)/$*.$(LIB_SUFFIX); fi; \
    if [ -f $(<D)/$*.$(LIB_SUFFIX) ]; then $(MV) $(<D)/$*.$(LIB_SUFFIX) $(LIB_PATH)/$*.$(LIB_SUFFIX); fi;
  endef
else
  define MOVE_LIB_RULE
    $(ECHO) -n;
  endef
  ifneq ($(LIB_OUTPUT),FLAGS)
    $(error Variable LIB_OUTPUT in <Makefile> is not set correctly)
  endif
endif

ifeq ($(ERR_TO_STDOUT),1)
  #-------------------------------------------------------------------------
  # $(PRINT_ERR_TO_STDOUT) prints error file to stdout
  # Turn it on by setting the environment/make variable $(ERR_TO_STDOUT)
  #-------------------------------------------------------------------------
  define PRINT_ERR_TO_STDOUT
    if [ -f $(ERR_PATH)/$*.$(ERR_SUFFIX) ]; then \
      $(CAT) $(ERR_PATH)/$*.$(ERR_SUFFIX); \
    fi;
  endef

  define RM_ERR_FILE
    if [ -f $(ERR_PATH)/$*.$(ERR_SUFFIX) ]; then \
      $(RM) $(ERR_PATH)/$*.$(ERR_SUFFIX); \
    fi;
  endef
endif

ifeq ($(ERR_OUTPUT),MOVE)
  #-------------------------------------------------------------------------
  # $(MOVE_ERR_RULE) moves generated .$(ERR_SUFFIX) files to a specific
  # output dir. If the variable $(ERR_OUTPUT) is set to MOVE in the
  # Makefile, this rule provides automatic movement of the generated error
  # file to the $(ERR_PATH)
  #-------------------------------------------------------------------------
  define MOVE_ERR_RULE
    $(ECHO) "Moving error file: $*.$(ERR_SUFFIX) -> $(ERR_PATH)/$*.$(ERR_SUFFIX)"; \
    if [ -f $*.$(ERR_SUFFIX) ]; then $(MV) $*.$(ERR_SUFFIX) $(ERR_PATH)/$*.$(ERR_SUFFIX); fi;
  endef
else
  define MOVE_ERR_RULE
    $(ECHO) -n;
  endef
  ifeq ($(ERR_OUTPUT),PIPE)
    WHITESPACE :=
    REDIRECT_OUTPUT = > $(ERR_PATH)/$*.$(ERR_SUFFIX) 2>&1 $(WHITESPACE) # whitespace at the end to avoid errors with shell (qb)
  else
    ifneq ($(ERR_OUTPUT),FLAGS)
      $(error Variable ERR_OUTPUT in <Makefile> is not set correctly)
    endif
  endif
endif

##############################################################################
# Default targets and rules
##############################################################################

#-----------------------------------------------------------------------------
# A phony target is one that is not really the name of a file. It is just a
# name for some commands to be executed when you make an explicit request.
# There are two reasons to use a phony target: to avoid a conflict with a file
# of the same name, and to improve performance.
#-----------------------------------------------------------------------------
.PHONY: delete_dld all clean compile depend default distclean clean_startAppl cleanlibs inf force help rebuild library inclists buildFiles

.PHONY: pclint visual visual10 visual12 codewright del_codewright_pjt doxygen preprocess slick slick10 resource qac qacinfo \
        releasesheet RESOURCE_NOT_SET size-all size-%.$(OBJ_SUFFIX) copylibs

inclists:
	@$(ECHO) "Common_Inc:"; \
     $(ECHO) "$(COMMON_INC)"; \
     $(ECHO) "FblCan:"; \
     $(ECHO) "$(FBLCAN_INC)"; \
     $(ECHO) "Gendata:"; \
     $(ECHO) "$(GENDATA_DIR)"; \
     $(ECHO) "Static BSW:"; \
     $(ECHO) "$(SUBDIRS)"; \
     $(ECHO) "Compiler:"; \
     $(ECHO) "$(COMPILER_INC)"; \
     $(ECHO) "Additional:"; \
     $(ECHO) "$(ADDITIONAL_INCLUDES)"; \
     $(ECHO) "Component makefiles:"; \
     $(ECHO) "$(COMP_MAKE_INC)";

force: ;

buildFiles:
	@$(ECHO) "MODULE_SOURCE_LST:"; \
     $(foreach SRC, $(MODULE_SOURCE_LST),$(ECHO) "$(SRC)";) \
     $(ECHO) "MODULE_HEADER_LST:"; \
     $(foreach INC, $(MODULE_HEADER_LST),$(ECHO) "$(INC)";) \
     $(ECHO) "MODULE_DATA_LST:"; \
     $(foreach SRC, $(MODULE_DATA_LST),$(ECHO) "$(SRC)";) \
     $(ECHO) "MODULE_COMMON_LST:"; \
     $(foreach SRC, $(MODULE_COMMON_LST),$(ECHO) "$(SRC)";) \
     $(ECHO) "APP_SOURCE_LST:"; \
     $(foreach SRC, $(APP_SOURCE_LST),$(ECHO) "$(SRC)";) \
     $(ECHO) "ASM_SOURCES:"; \
     $(foreach SRC, $(ASM_SOURCES),$(ECHO) "$(SRC)";) \
     $(ECHO) "GEN_SOURCES:"; \
     $(foreach SRC, $(GEN_SOURCES),$(ECHO) "$(SRC)";) \
     $(ECHO) "GEN_HEADERS:"; \
     $(foreach INC, $(GEN_HEADERS),$(ECHO) "$(INC)";) \
     $(ECHO) "THIRD_PARTY_SOURCES:"; \
     $(foreach SRC, $(THIRD_PARTY_SOURCES),$(ECHO) "$(SRC)";) \
     $(ECHO) "THIRD_PARTY_HEADERS:"; \
     $(foreach INC, $(THIRD_PARTY_HEADERS),$(ECHO) "$(INC)";) \
     $(ECHO) "COMPILER_SOURCES:"; \
     $(foreach SRC, $(COMPILER_SOURCES),$(ECHO) "$(SRC)";) \
     $(ECHO) "COMPILER_HEADERS:"; \
     $(foreach INC, $(COMPILER_HEADERS),$(ECHO) "$(INC)";) \
     $(ECHO) "ALL OTHER HEADERS:"; \
     $(foreach INC, $(filter-out $(MODULE_HEADER_LST) $(GEN_HEADERS) $(THIRD_PARTY_HEADERS) $(COMPILER_HEADERS),$(HEADERS)),$(ECHO) "$(INC)";)

#-----------------------------------------------------------------------------
# deletes previously generated/outdated Linker-script file
# (otherwise, Makesupport ignores changes within Linker command file *.make)
#-----------------------------------------------------------------------------
delete_dld:
	@$(ECHO) "Delete previous generated Linker-script (if existing) ..."; \
  if [ -f $(PROJECT_NAME).$(LNK_SUFFIX) ] ; then                        \
    $(ECHO) "-> Delete $(PROJECT_NAME).$(LNK_SUFFIX) ...";              \
    $(RM) $(PROJECT_NAME).$(LNK_SUFFIX);                                \
  fi;                                                                   \
  $(ECHO);

all: inf                                            \
     $(if $(findstring 1,$(DELETE_DLD)),delete_dld) \
     $(PROJECT_NAME).$(BINARY_SUFFIX)
	@$(ECHO);           \
  if [ -f ..\\A2L_AdressUpdate.bat ] ; then \
    $(ECHO) "File A2L_AdressUpdate.bat found, executed for StartApplication UseCase XCP ..." ; \
    $(ECHO); \
    cmd /C ..\\A2L_AdressUpdate.bat ; \
    $(ECHO); \
    $(ECHO) "Updated A2L File" ; \
  fi ; \
  $(ECHO); \
  $(ECHO) "...done!"; \
  $(ECHO)

#-----------------------------------------------------------------------------
# prints information about used cpu/derivative
# -> from v_cfg.h
#-----------------------------------------------------------------------------
inf:
ifeq ($(V_CFG_DETECTED),1)
	@$(ECHO) "Derivative (CPU type) found in v_cfg.h -> $(DERIVATIVE)"; \
  $(ECHO);
else
	@$(ECHO) "Derivative (CPU type) (preselected in Makefile/Makefile.config) -> $(DERIVATIVE)"; \
  $(ECHO);
endif

#-----------------------------------------------------------------------------
# rebuild the whole project
#-----------------------------------------------------------------------------
rebuild:
	@$(ECHO) "Complete rebuild of project started ...";                               \
  "$(MAKE)" clean;                                                                  \
  if [ -f $(GENDATA_DIR_U)/BrsVInfo.h ] && [ -w $(GENDATA_DIR_U)/BrsVInfo.h ]; then \
    $(RM) $(GENDATA_DIR_U)/BrsVInfo.h;                                              \
  fi;                                                                               \
  if [ -f $(PROJECT_NAME).dep ] ; then                                              \
    $(RM) $(PROJECT_NAME).dep;                                                      \
  fi;                                                                               \
 "$(MAKE)" default

#-----------------------------------------------------------------------------
# prints versions of used tools
#-----------------------------------------------------------------------------
VERSION_DIR = $(subst / , ,$(subst ???,\ ,$(sort $(foreach DIR,          \
                $(filter-out                                             \
                  $(subst / , ,                                          \
                    $(subst \,/,$(subst \ ,???,                          \
                      $(call _toLower,$(COMPILER_INC))                   \
                      $(call _toLower,$(OBJ_PATH))                       \
                    ))                                                   \
                  ),                                                     \
                  $(subst / , ,                                          \
                    $(subst \,/,$(subst \ ,???,                          \
                      $(call _toLower,$(SUBDIRS))                        \
                    ))                                                   \
                    $(dir $(subst \,/,$(subst \ ,???,                    \
                      $(call _toLower,$(INCFILE_LIST))                   \
                    )))                                                  \
                  )                                                      \
                )                                                        \
              ,"$(DIR)"))))

VERSION_SCAN_DIRS = \
                 $(subst ???,\ ,                                         \
                   $(filter-out                                          \
                     $(subst / , ,                                       \
                       $(subst \,/,                                      \
                         $(subst \ ,???,                                 \
                           $(call _toLower, $(COMPILER_INC) $(OBJ_PATH)) \
                         )                                               \
                       )                                                 \
                     ),                                                  \
                     $(subst / , ,                                       \
                       $(subst \,/,                                      \
                         $(subst \ ,???,                                 \
                           $(call _toLower, $(SUBDIRS) $(INCDIR_LIST))   \
                         )                                               \
                       )                                                 \
                     )                                                   \
                   )                                                     \
                 )

VERSION_SCAN_FILES =                                                     \
        $(foreach FILE,                                                  \
            $(subst \ ,???,                                              \
              $(INCFILE_LIST_UNIX) $(filter-out $(VERSION_INFO_FILTEROUT_LST),$(SOURCES_UNIX)) \
            ),                                                           \
            $(subst ???, ,"$(FILE)")                                     \
        )

#-----------------------------------------------------------------------------
# Defines used for releasesheet & resource
#-----------------------------------------------------------------------------

VERSION_INFO_FILE = $(subst \,/,$(GENTOOL_DIR)/version.info)

ifneq ($(shell if [ -f $(VERSION_INFO_FILE) ]; then $(ECHO) $(VERSION_INFO_FILE); fi),)
BLANK = #
FROM_VINFO_CBD        = $(firstword $(shell $(GAWK) -v IGNORECASE=1 "{gsub(/ /, \"_\")} /<CBD>/ {match(\$$0, /<CBD>(.*)<\/CBD>/, r);print r[1];}" $(VERSION_INFO_FILE)) UNKNOWN_CBD)
FROM_VINFO_SIP        = $(firstword $(shell $(GAWK) -v IGNORECASE=1 "{gsub(/ /, \"_\")} /<SIP>/ {match(\$$0, /<SIP>(.*)<\/SIP>/, r);print r[1];}" $(VERSION_INFO_FILE)) UNKNOWN_SIP)
FROM_VINFO_OEM        = $(firstword $(shell $(GAWK) -v IGNORECASE=1 "{gsub(/ /, \"_\")} /<OEM>/ {match(\$$0, /<OEM>(.*)<\/OEM>/, r);print r[1];}" $(VERSION_INFO_FILE)) UNKNOWN_OEM)
FROM_VINFO_SLP        = $(firstword $(shell $(GAWK) -v IGNORECASE=1 "{gsub(/ /, \"_\")} /<SLP>/ {match(\$$0, /<SLP>(.*)<\/SLP>/, r);print r[1];}" $(VERSION_INFO_FILE)) UNKNOWN_SLP)
FROM_VINFO_CONTROLLER = $(firstword $(shell $(GAWK) -v IGNORECASE=1 "{gsub(/ /, \"_\")} /<Controller>/ {match(\$$0, /<Controller>(.*)<\/Controller>/, r);print r[1];}" $(VERSION_INFO_FILE)) UNKNOWN_Controller)
FROM_VINFO_CANCELL    = $(firstword $(shell $(GAWK) -v IGNORECASE=1 "{gsub(/ /, \"_\")} /<CanCell>/ {match(\$$0, /<CanCell>(.*)<\/CanCell>/, r);print r[1];}" $(VERSION_INFO_FILE)) UNKNOWN_CanCell)
FROM_VINFO_COMPILER   = $(firstword $(shell $(GAWK) -v IGNORECASE=1 "{gsub(/ /, \"_\")} /<Compiler>/ {match(\$$0, /<Compiler>(.*)<\/Compiler>/, r);print r[1];}" $(VERSION_INFO_FILE)) UNKNOWN_Compiler)
# Specifies how the filenames for the releasesheet & resource info files are named.
RESOURCE_FILENAME     = $(FROM_VINFO_SLP).$(FROM_VINFO_OEM).$(FROM_VINFO_COMPILER).$(FROM_VINFO_CONTROLLER).$(FROM_VINFO_SIP).$(FROM_VINFO_CBD)
RESOURCE_TARGETDIR    = $(subst $(_OPEN_PAREN),,$(subst $(_CLOSE_PAREN),,$(RESOURCE_FILENAME)))
RESOURCE_COPYFILES    = ../CANdb/*.gny ../CANdb/*.arxml ../Config/*.gny ../Config/*.arxml
endif

#-----------------------------------------------------------------------------
# xml file which contains tool version and settings (processed by xslt processor)
#-----------------------------------------------------------------------------
makesupport.xml: force
	@$(ECHO) "Generating makesupport version information file (->$(subst /,\\,$@))";                       \
 $(ECHO) "<?xml version='1.0' encoding='UTF-8'?>"                                                        > $@; \
 $(ECHO) "<makesupport>"                                                                                >> $@; \
 $(ECHO) "<controller name='$(PLATFORM)' derivative='$(DERIVATIVE)' />"                                 >> $@; \
 $(ECHO) " <devtoolinfo>"                                                                               >> $@; \
 if [ -n '$(CC)' ]; then                                                                                       \
 $(ECHO) "    <tool type='Compiler' manufacturer='$(COMPILER_MANUFACTURER)'>"                           >> $@; \
 $(ECHO) "      <entry type='Version'>$(CC_VERSION_STRING)</entry>"                                     >> $@; \
 if [ "$(CFLAGS_SELECTOR)" = "CUSTOMER" ]; then                                                                \
  $(ECHO) "      <entry type='RequestedCustomerOptions'>$(CFLAGS_CUSTOMER_OPTIONS)</entry>"             >> $@; \
 else                                                                                                          \
  $(ECHO) "      <entry type='VectorDefaultOptions'>$(CFLAGS_VECTOR_OPTIONS)</entry>"                   >> $@; \
 fi;                                                                                                           \
 $(ECHO) "      <entry type='VectorBuildEnvironmentOptions'>$(CFLAGS_VECTOR_MAKESUPPORT)</entry>"       >> $@; \
 $(ECHOESC) $(foreach FILE,$(filter-out $(SOURCES_APPL_UNIX),$(SOURCES_UNIX)),                                 \
                $(if $(CFLAGS_$(call _toUpper,$(basename $(notdir $(FILE))))),                                 \
                  "      <entry type='AdditionalOptions $(basename $(notdir $(FILE))).$(OBJ_SUFFIX)'>          \
                     $(CFLAGS_$(call _toUpper,$(basename $(notdir $(FILE)))))</entry>"                         \
                  ,)                                                                                           \
               )                                                  >> $@;                                       \
 $(ECHOESC) $(foreach FILE,$(filter-out $(SOURCES_APPL_UNIX),$(SOURCES_UNIX)),                                 \
                $(if $(FILTER_$(call _toUpper,$(basename $(notdir $(FILE))))),                                 \
                  "      <entry type='FilteredOptions $(basename $(notdir $(FILE))).$(OBJ_SUFFIX)'>            \
                     $(FILTER_$(call _toUpper,$(basename $(notdir $(FILE)))))</entry>"                         \
                  ,)                                                                                           \
               )                                                  >> $@;                                       \
 $(ECHO) "    </tool>"                                                                                  >> $@; \
 fi;                                                                                                           \
 if [ -n '$(AS)' ]; then                                                                                       \
 $(ECHO) "    <tool type='Assembler' manufacturer='$(COMPILER_MANUFACTURER)'>"                          >> $@; \
 $(ECHO) "      <entry type='Version'>$(AS_VERSION_STRING)</entry>"                                     >> $@; \
 if [ "$(ASFLAGS_SELECTOR)" = "CUSTOMER" ]; then                                                               \
  $(ECHO) "      <entry type='RequestedCustomerOptions'>$(ASFLAGS_CUSTOMER_OPTIONS)</entry>"            >> $@; \
 else                                                                                                          \
  $(ECHO) "      <entry type='VectorDefaultOptions'>$(ASFLAGS_VECTOR_OPTIONS)</entry>"                  >> $@; \
 fi;                                                                                                           \
 $(ECHO) "      <entry type='VectorBuildEnvironmentOptions'>$(ASFLAGS_VECTOR_MAKESUPPORT)</entry>"      >> $@; \
 $(ECHO) "    </tool>"                                                                                  >> $@; \
 fi;                                                                                                           \
 if [ -n '$(LD)' ]; then                                                                                       \
 $(ECHO) "    <tool type='Linker' manufacturer='$(COMPILER_MANUFACTURER)'>"                             >> $@; \
 $(ECHO) "      <entry type='Version'>$(LD_VERSION_STRING)</entry>"                                     >> $@; \
 if [ "$(LDFLAGS_SELECTOR)" = "CUSTOMER" ]; then                                                               \
  $(ECHO) "      <entry type='RequestedCustomerOptions'>$(LDFLAGS_CUSTOMER_OPTIONS)</entry>"            >> $@; \
 else                                                                                                          \
  $(ECHO) "      <entry type='VectorDefaultOptions'>$(LDFLAGS_VECTOR_OPTIONS)</entry>"                  >> $@; \
 fi;                                                                                                           \
 $(ECHO) "      <entry type='VectorBuildEnvironmentOptions'>$(LDFLAGS_VECTOR_MAKESUPPORT)</entry>"      >> $@; \
 $(ECHO) "    </tool>"                                                                                  >> $@; \
 fi;                                                                                                           \
 if [ -n '$(EXT_T1)' ]; then                                                                                   \
 $(ECHO) "    <tool type='ExternalTool1'>"                                                              >> $@; \
 $(ECHO) "      <entry type='Version'>$(EXT_T1_VERSION_STRING)</entry>"                                 >> $@; \
 $(ECHO) "      <entry type='Flags'>$(EXT_T1_FLAGS)</entry>"                                            >> $@; \
 $(ECHO) "    </tool>"                                                                                  >> $@; \
 fi;                                                                                                           \
 if [ -n '$(EXT_T2)' ]; then                                                                                   \
 $(ECHO) "    <tool type='ExternalTool2'>"                                                              >> $@; \
 $(ECHO) "      <entry type='Version'>$(EXT_T2_VERSION_STRING)</entry>"                                 >> $@; \
 $(ECHO) "      <entry type='Flags'>$(EXT_T2_FLAGS)</entry>"                                            >> $@; \
 $(ECHO) "    </tool>"                                                                                  >> $@; \
 fi;                                                                                                           \
 $(ECHO) " </devtoolinfo>"                                                                              >> $@; \
 $(ECHO) "</makesupport>"                                                                               >> $@; \
 $(ECHO) "...done";                                                                                            \
 $(ECHO) ;

#-----------------------------------------------------------------------------
# releasesheet target
# VERSION_INFO_FILE is only set when Version.Info is found in /components directory of geny
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Print variables: display any value from a makefile variable
# e.g. print-COMPILER_BASE
#-----------------------------------------------------------------------------
print-% : ; @echo $* = "$($*)"

#-----------------------------------------------------------------------------
# Delivery Description target dir is $(ROOT)\_Doc for old deliveries(fbl), $(ROOT)\Doc for new 
# deliveries and $(LOG_PATH) if both doesn't exist.
#-----------------------------------------------------------------------------
DESC_PATH_ALT = $(shell if [ -d $(subst \,/,$(ROOT)\_Doc) ] ;then  \
                        $(ECHO) '$(ROOT)\_Doc' ;                   \
                      else                                         \
                        $(ECHO) '$(LOG_PATH)'  ;                   \
                       fi)

DESC_PATH = $(shell if [ -d $(subst \,/,$(ROOT)\Doc\DeliveryInformation) ] ;then \
                    $(ECHO) '$(ROOT)\Doc\DeliveryInformation' ;                  \
                  else                                         \
                    $(ECHO) '$(DESC_PATH_ALT)'  ;              \
                   fi)

DESC_PATH_UNIX = $(subst ???,\ ,$(subst \,/,$(subst \ ,???,$(DESC_PATH))))

RELEASESHEET_FILENAME = DeliveryDescription_$(FROM_VINFO_CBD).html

deliverydescription: $(DESC_PATH_UNIX)/$(RELEASESHEET_FILENAME)

dd: $(DESC_PATH_UNIX)/$(RELEASESHEET_FILENAME)

ifneq ($(PLATFORM),VTT_ONLY)
  $(DESC_PATH_UNIX)/$(RELEASESHEET_FILENAME): makesupport.xml
	@if [ -d $(DESC_PATH_UNIX) ] ; then :;                                                                                     \
     else                                                                                                                    \
       $(ECHO) "Generating directory $(DESC_PATH_UNIX)";                                                                     \
       $(MKDIR) $(DESC_PATH_UNIX);                                                                                           \
       $(ECHO) ;                                                                                                             \
     fi;                                                                                                                     \
     if [ -f $(VERSION_INFO_FILE) ]; then                                                                                    \
     if [ -f $(XSLT) ] ; then                                                                                                \
       $(CP) $(RELSHEET_XSL) script.xslt;                                                                                    \
       $(XSLT) -x script.xslt -i $(VERSION_INFO_FILE) -o $@ 1>/dev/null 2>/dev/null;                                         \
       $(ECHO) ;                                                                                                             \
       $(ECHO) "Generated file: $@";                                                                                         \
       $(RM) script.xslt;                                                                                                    \
     else                                                                                                                    \
       $(ECHO) "XSLT processor not found. Please update your _MakeSupport/cmd directory!";                                   \
     fi;                                                                                                                     \
   else                                                                                                                      \
     $(ECHO) "$(VERSION_INFO_FILE) could not be found! Please adjust GENTOOL_DIR variable in Makefile.project.part.defines"; \
   fi;                                                                                                                       \
   $(RM) makesupport.xml

else
  $(DESC_PATH_UNIX)/$(RELEASESHEET_FILENAME):
	@if [ -d $(DESC_PATH_UNIX) ] ; then :;                                                                                     \
     else                                                                                                                    \
       $(ECHO) "Generating directory $(DESC_PATH_UNIX)";                                                                     \
       $(MKDIR) $(DESC_PATH_UNIX);                                                                                           \
       $(ECHO) ;                                                                                                             \
     fi;                                                                                                                     \
     if [ -f $(VERSION_INFO_FILE) ]; then                                                                                    \
     if [ -f $(XSLT) ] ; then                                                                                                \
       $(CP) $(RELSHEET_XSL) script.xslt;                                                                                    \
       $(XSLT) -x script.xslt -i $(VERSION_INFO_FILE) -o $@ 1>/dev/null 2>/dev/null;                                         \
       $(ECHO) ;                                                                                                             \
       $(ECHO) "Generated file: $@";                                                                                         \
       $(RM) script.xslt;                                                                                                    \
     else                                                                                                                    \
       $(ECHO) "XSLT processor not found. Please update your _MakeSupport/cmd directory!";                                   \
     fi;                                                                                                                     \
   else                                                                                                                      \
     $(ECHO) "$(VERSION_INFO_FILE) could not be found! Please adjust GENTOOL_DIR variable in Makefile.project.part.defines"; \
   fi;
endif

MODULE_LIST_VERSION_MATCHING += COMMON_VDEF \
                                CANGEN

MODULE_LIST_VERSION_IGNORE += CANGENEXE   \
                              VGEN_CANGEN \
                              CC_GET_CCP

#-----------------------------------------------------------------------------
# clean up err/lst/obj files
#-----------------------------------------------------------------------------
CLEAN_PATTERN_LIST =  $(LST_N_MAP_LIST_WOP) \
                      $(PROJECT_NAME).$(BINARY_SUFFIX) \
                      $(DEL_PATTERN_LIST)

CLEAN_PATTERN_LIST_UNIX   = $(subst \,/,$(CLEAN_PATTERN_LIST))

clean: $(MAKE_CLEAN_RULES)
	-@$(ECHO) "Deleting $(CLEAN_PATTERN_LIST)"; \
 for pattern in $(CLEAN_PATTERN_LIST_UNIX); do \
  $(RM) $$pattern 2>/dev/null;  \
 done; \
 $(ECHO)

#-----------------------------------------------------------------------------
# clean up everything
#-----------------------------------------------------------------------------
distclean: del_codewright_pjt
	-@$(ECHO) "Deleting $(DEL_PATTERN_LIST)";                           \
  $(RM) $(DEL_PATTERN_LIST_UNIX) 2>/dev/null;                         \
  $(RRM) $(OBJ_PATH) $(ERR_PATH) $(LST_PATH) $(LOG_PATH) $(LIB_PATH); \
  $(ECHO) "Deleting $(DIST_CLEAN_LIST) in:";                          \
  for subdir in $(CLEANDIRS_UNIX); do                                 \
    $(ECHO) "   $$subdir";                                            \
    for pattern in $(subst \,/,$(DIST_CLEAN_LIST)); do                \
      for file in $$subdir/$$pattern; do                              \
        if [ $$file != "./Makefile.project.part.defines" ] ; then     \
          if [ -f $$file ] && [ -w $$file ]; then                     \
            $(RM) $$file 2>/dev/null;                                 \
          fi;                                                         \
        fi;                                                           \
      done;                                                           \
    done;                                                             \
  done;                                                               \
  $(ECHO)

#-----------------------------------------------------------------------------
# clean up nant, eclipse, debugger dirs, .cproject, etc. for StartApplication
#-----------------------------------------------------------------------------
clean_startAppl: 
	-@$(ECHO) "Deleting $(DEL_PATTERN_LIST)";                          \
  "$(MAKE)" nant_rm_all;                                             \
  $(RRM) NAnt-Files                                                  \
  $(RRM) ../_Eclipse                                                 \
  $(RM) ../*.cproject 2>/dev/null;                                   \
  $(RM) ../*.project 2>/dev/null;                                    \
  $(RM) ../*.silent.dcusr  2>/dev/null;                              \
  $(RM) $(DEL_PATTERN_LIST_UNIX) 2>/dev/null;                        \
  $(RRM) $(OBJ_PATH) $(ERR_PATH) $(LST_PATH) $(LOG_PATH) $(LIB_PATH) \
  $(RRM) $(OBJ_PATH)/../$(DEP_SUFFIX) $(OBJ_PATH)/../_lauterbach $(OBJ_PATH)/../UDE* $(OBJ_PATH)/../iSystem*; \
  $(ECHO) "Deleting $(REINL_CLEAN_LIST) in:";                        \
  for subdir in $(CLEANDIRS_UNIX); do                                \
    $(ECHO) "   $$subdir";                                           \
    for pattern in $(subst \,/,$(REINL_CLEAN_LIST)); do              \
      for file in $$subdir/$$pattern; do                             \
        if [ $$file != "./Makefile.project.part.defines" ] ; then    \
          if [ -f $$file ] && [ -w $$file ]; then                    \
            $(RM) $$file 2>/dev/null;                                \
          fi;                                                        \
        fi;                                                          \
      done;                                                          \
    done;                                                            \
  done;                                                              \
  $(ECHO)

#-----------------------------------------------------------------------------
# link all objects together
#-----------------------------------------------------------------------------
LINK_RULE_Q=$(subst ",',$(subst \,/,$(LINK_RULE)))

# If GEN7 OS is used, add all generated linker files to the dependency list
ifeq ($(OS_USECASE), OSGEN7)
OS_GEN7_LINK_FILES = $(wildcard $(GENDATA_DIR)/Os_Link*)
endif

$(PROJECT_NAME).$(BINARY_SUFFIX): %.$(BINARY_SUFFIX): $(OBJECTS_U) \
                                  Makefile                         \
                                  $(MAKEFILE_CONFIG)               \
                                  Makefile.$(PLATFORM).$(COMPILER_MANUFACTURER).$(EMULATOR).make    \
                                  $(if $(USER_LINKER_COMMAND_FILE),, $(PROJECT_NAME).$(LNK_SUFFIX)) \
                                  $(OS_GEN7_LINK_FILES)
	@$(ECHO);                  \
  $(ECHO) "Linking files: "; \
  $(ECHO) "    $(OBJECTS)";  \
  $(RM_ERR_FILE)             \
  if ( $(LINK_RULE) ) ; then \
    $(PRINT_ERR_TO_STDOUT)   \
  else                       \
    $(PRINT_ERR_TO_STDOUT)   \
    exit 1;                  \
  fi

ifneq ($(NEW_DEPENDENCY_FORMAT),1)
#-----------------------------------------------------------------------------
# create project dependencies
#-----------------------------------------------------------------------------
ifeq ($(MAKEDEP_OFF),)
DEP_FILES = $(PREDEP)                     \
            Makefile                      \
            $(MAKEFILE_CONFIG)            \
            Makefile.project.part.defines \
            $(MAKESUPPORT_DIR)/Global.Makefile.target.make.$(VERSION)
endif

ifneq ($(PLATFORM),VTT_ONLY)
  $(PROJECT_NAME).dep: $(DEP_FILES)
	@$(MAKE_DEPEND_RULE)
endif

depend:
	@$(MAKE_DEPEND_RULE)

define MAKE_DEPEND_RULE
  $(ECHO) "# this file is generated automatically by MakeSupport"                       \
    > $(PROJECT_NAME).dep;                                                              \
  $(ECHO) >> $(PROJECT_NAME).dep;                                                       \
  if [ -d $(LOG_PATH) ] ; then :;                                                       \
  else                                                                                  \
    $(ECHO) "Generating directory $(LOG_PATH)";                                         \
    $(MKDIR) $(LOG_PATH);                                                               \
    $(ECHO) ;                                                                           \
  fi;                                                                                   \
  if [ -f $(LOG_PATH)/makedep.txt ] ; then                                              \
    $(RM) $(LOG_PATH)/makedep.txt;                                                      \
  fi;                                                                                   \
  $(ECHO) Making dependencies for | $(TEE) $(LOG_PATH)/makedep.txt;                     \
  for FILE in $(DEPENDENCY_SOURCES_UNIX); do                                            \
    if [ -z "$(MKVERBOSE)" ] ; then                                                     \
      $(ECHO) "    $$FILE" |                                                            \
        $(TEE) $(LOG_PATH)/makedep.txt;                                                 \
    else                                                                                \
      $(ECHO) "    $(MAKEDEPEND) $(CPPFLAGS) $(GCCINCLUDES) $$FILE" |                   \
        $(TEE) $(LOG_PATH)/makedep.txt;                                                 \
    fi;                                                                                 \
    $(MAKEDEPEND) $(CPPFLAGS) $(GCCINCLUDES) $$FILE 2>makedep.tmp |                     \
      $(SED) '/\(.*\)\.o:\ \\/{;s/o:\ \\/o:/g;N;s/\n//g;};s/\(.*\)\.o:\ \(.*\.[cC][pP]\{0,1\}[pP]\{0,1\}\)\{0,1\}\(\ .*\)\{0,1\}/$(OBJ_PATH)\/\1.$(OBJ_SUFFIX):\ \2 $(MAKEFILE_CONFIG)\ \3/g' \
                                                              >> $(PROJECT_NAME).dep;   \
    $(CAT) makedep.tmp >> $(LOG_PATH)/makedep.txt;                                      \
    $(CAT) makedep.tmp;                                                                 \
    $(RM) makedep.tmp;                                                                  \
  done;                                                                                 \
  $(ECHO)                                                       >> $(PROJECT_NAME).dep; \
  $(ECHO) "# Manual file dependencies"                          >> $(PROJECT_NAME).dep; \
  $(ECHOESC) $(foreach FILE,$(SOURCES_UNIX),                                            \
             "$(if $(findstring $(notdir $(FILE)),$(DEPENDENCY_IGNORE_LIST)),\n$(OBJ_PATH)/$(basename $(notdir $(FILE))).$(OBJ_SUFFIX): $(FILE) force,)" \
             )                                                  >> $(PROJECT_NAME).dep; \
  $(ECHO)                                                       >> $(PROJECT_NAME).dep; \
  $(ECHO) "# Assembler file dependencies"                       >> $(PROJECT_NAME).dep; \
  $(ECHOESC) $(foreach ASM,$(subst \,/,$(ASM_SOURCES)),                                 \
             "\n$(OBJ_PATH)/$(basename $(notdir $(ASM))).$(OBJ_SUFFIX): $(ASM) $(MAKEFILE_CONFIG)" \
             )                                                  >> $(PROJECT_NAME).dep; \
  $(ECHO)                                                       >> $(PROJECT_NAME).dep; \
  $(ECHO)                                                       >> $(PROJECT_NAME).dep; \
  $(ECHOESC) $(foreach LIB,$(sort $(BUILD_LIBS)),                                       \
             "\n$(LIB): "                                                               \
             "$(strip $(subst \,/,$(call libObjects,$(basename $(notdir $(LIB))))))"    \
             )                                                  >> $(PROJECT_NAME).dep; \
  $(ECHO);
endef

DEPENDENCY_SOURCES_UNIX = $(foreach FILE,$(call safeSort,$(SOURCES_UNIX) $(LIB_SOURCES_UNIX)), \
                              $(if $(findstring $(notdir $(FILE)),$(DEPENDENCY_IGNORE_LIST)),,$(FILE)) \
                            )
else #ifneq ($(NEW_DEPENDENCY_FORMAT),1)
# Directory in which the dependencies will be stored
DEP_DIR = dep

# Remove all dependency files during clean if new dependency format is used
DEL_PATTERN_LIST       += $(DEP_DIR)/*.c.d $(DEP_DIR)/*.$(LIB_SUFFIX).d $(DEP_DIR)/*.$(ASM_SUFFIX).d

# Create dependency file names from source file names
DEPENDENCY_FILES_FOR_ASM_SOURCES = $(addprefix $(DEP_DIR)/, $(addsuffix .d, $(notdir $(ASM_SOURCES))))
DEPENDENCY_FILES_FOR_SOURCES_UNIX = $(addprefix $(DEP_DIR)/, $(addsuffix .d, $(notdir $(SOURCES_UNIX))))
DEPENDENCY_FILES_FOR_BUILD_LIBS = $(addprefix $(DEP_DIR)/, $(addsuffix .d, $(notdir $(sort $(BUILD_LIBS)))))

# Files wholse change will cause a rebuild of object files
# The $(wildcard ...) function will remove non existing files from the list
ADDITIONAL_OBJECT_FILE_DEPENDENCIES = $(wildcard Makefile.config)

# Set search directory for source files
# $(sort ...) will remove duplicate entries
vpath %.c $(sort $(dir $(SOURCES_UNIX)))

# Set search directory for assembler files
# $(subst \,/,...) is used because it seems that vpath cannot handle backslashes in directories
# $(sort ...) is used to remove duplicate entries from the list
vpath %.$(ASM_SUFFIX) $(subst \,/, $(sort $(dir $(ASM_SOURCES))))

depend: $(DEPENDENCY_FILES_FOR_SOURCES_UNIX) $(DEPENDENCY_FILES_FOR_ASM_SOURCES) $(DEPENDENCY_FILES_FOR_BUILD_LIBS)

# Target to create depencency file from *.c files
# $< is the first depencency of the target, in this case the path to the source file
# $@ is the path to the dependency file
# Since the used GNU make version (3.79.1) doesn't support order only prerequisites (introduced in 3.80),
# the dependency directory must be created in every dependency file target. Using phony targets will not work,
# it causes rebuilds all the time. See https://www.gnu.org/software/make/manual/make.html#Phony-Targets
$(DEP_DIR)/%.c.d: %.c $(ADDITIONAL_OBJECT_FILE_DEPENDENCIES)
	@if [ ! -d $(DEP_DIR) ]; then $(MKDIR) -p $(DEP_DIR); fi
	@$(ECHO) "Updating dependency file for $<";
# Run CPP0 for source file ($<) and redirect output to <target>.tmp file
	@$(MAKEDEPEND) $(CPPFLAGS) $(GCCINCLUDES) $< -M -MT -MD $@.tmp
# Run sed to replace target object file (e.g. Test.o:) with real path (e.g. obj/Test.o:)
# Furthermore the dependeny file is added as target. $(subst /,\/,$@) will replace "/" by "\/" (escaping for sed)
# Adding the dependency file as target is used to rebuild the dependency file in case of changed source files
# $(subst /,\/,$<) will add the source file path as FIRST dependency followed by additional dependencies
# The source file MUST always be the first dependency of the targets because the build rule relies on it
# This operation is not portable (CPP0 only) and creates redundant dependencies (source file is present twice)
# but avoids writing more complex SED scripts
	@$(SED) -e 's/$(basename $(notdir $<)).o:/obj\/$(basename $(notdir $<)).o $(subst /,\/,$@): $(subst /,\/,$<) $(ADDITIONAL_OBJECT_FILE_DEPENDENCIES)/g' $@.tmp > $@
	@$(RM) $@.tmp

# Target to create depencency file from assembler files
# $< is the first depencency of the target, in this case the path to the assembler file
# $@ is the path to the dependency file
# Since the used GNU make version (3.79.1) doesn't support order only prerequisites (introduced in 3.80),
# the dependency directory must be created in every dependency file target. Using phony targets will not work,
# it causes rebuilds all the time. See https://www.gnu.org/software/make/manual/make.html#Phony-Targets
$(DEP_DIR)/%.$(ASM_SUFFIX).d: %.$(ASM_SUFFIX) $(ADDITIONAL_OBJECT_FILE_DEPENDENCIES)
	@if [ ! -d $(DEP_DIR) ]; then $(MKDIR) -p $(DEP_DIR); fi
	@$(ECHO) "Updating dependency file for $<";
	@$(ECHO) "$(OBJ_PATH)/$(basename $(notdir $<)).$(OBJ_SUFFIX): $< $(ADDITIONAL_OBJECT_FILE_DEPENDENCIES)" > $@

# Workaround for BRS environments where the assembler files don't use ASM_SUFFIX as extension
ifneq ($(ADDITIONAL_ASM_SUFFIX),)
# Add dependency files to cleanup list (for clean target)
DEL_PATTERN_LIST       += $(DEP_DIR)/*.$(ADDITIONAL_ASM_SUFFIX).d
# Set search directory for assembler files with different extension
# $(subst \,/,...) is used because it seems that vpath cannot handle backslashes in directories
# $(sort ...) is used to remove duplicate entries from the list
vpath %.$(ADDITIONAL_ASM_SUFFIX) $(subst \,/, $(sort $(dir $(filter %.$(ADDITIONAL_ASM_SUFFIX), $(ASM_SOURCES)))))

# Additional target for assembler files which don't use ASM_SUFFIX as extension
# Its the same target/rule like for "normal" assembler files with ASM_SUFFIX replaced by ADDITIONAL_ASM_SUFFIX
$(DEP_DIR)/%.$(ADDITIONAL_ASM_SUFFIX).d: %.$(ADDITIONAL_ASM_SUFFIX) $(ADDITIONAL_OBJECT_FILE_DEPENDENCIES)
	@if [ ! -d $(DEP_DIR) ]; then $(MKDIR) -p $(DEP_DIR); fi
	@$(ECHO) "Updating dependency file for $<";
	@$(ECHO) "$(OBJ_PATH)/$(basename $(notdir $<)).$(OBJ_SUFFIX): $< $(ADDITIONAL_OBJECT_FILE_DEPENDENCIES)" > $@

endif #ifneq ($(ADDITIONAL_ASM_SUFFIX),)

# Target to create depenency file for libraries
# $@ is the path to the dependency file
# $(basename $(notdir  $@)) will return the file name of the library (without directory)
# $(basename $(basename $(notdir $@))) will return the file name of the library without extension (without directory)
# Since the used GNU make version (3.79.1) doesn't support order only prerequisites (introduced in 3.80),
# the dependency directory must be created in every dependency file target. Using phony targets will not work,
# it causes rebuilds all the time. See https://www.gnu.org/software/make/manual/make.html#Phony-Targets
$(DEP_DIR)/%.$(LIB_SUFFIX).d:
	@if [ ! -d $(DEP_DIR) ]; then $(MKDIR) -p $(DEP_DIR); fi
	@$(ECHO) "Updating dependency file for $(LIB_PATH)/$(basename $(notdir $@))";
	@$(ECHO) "$(LIB_PATH)/$(basename $(notdir  $@)): $(call libObjects,$(basename $(basename $(notdir $@))))" > $@

endif #ifneq ($(NEW_DEPENDENCY_FORMAT),1)
#-----------------------------------------------------------------------------
# compiles all source files
#-----------------------------------------------------------------------------
compile: $(BUILD_OBJECTS_U)

#-----------------------------------------------------------------------------
# implicit rule to compile a single file
# (for targets obj_path/*.obj)
#-----------------------------------------------------------------------------
COMPILE_RULE_Q=$(subst ",',$(subst \,/,$(COMPILE_RULE)))
ASSEMBLE_RULE_Q=$(subst ",',$(subst \,/,$(ASSEMBLE_RULE)))

$(OBJ_PATH)/%.$(OBJ_SUFFIX):
	@for dir in $(DIR_LIST); do                                          \
    if [ -d $$dir ] ;                                                  \
      then :;                                                          \
    else                                                               \
      $(ECHO) "Generating directory $$dir";                            \
      $(MKDIR) $$dir;                                                  \
      $(ECHO) ;                                                        \
    fi;                                                                \
  done;                                                                \
  if [ -z "$<" ] ; then                                                \
    $(ECHO) "Dependencies missing for $@";                             \
    $(ECHO) "Please run \"m depend\" or adjust the Makefile properly"; \
    exit 1;                                                            \
  else                                                                 \
    $(RM_ERR_FILE)                                                     \
    $(if $(findstring $(ASM_SUFFIX),$(suffix $<)),                     \
      $(ECHO) "Assembling file: $<";                                   \
      if ( $(ASSEMBLE_RULE) ) ; then                                   \
        $(PRINT_ERR_TO_STDOUT)                                         \
        $(MOVE_OBJECT_RULE)                                            \
        $(MOVE_ERR_RULE)                                               \
      else                                                             \
        $(PRINT_ERR_TO_STDOUT)                                         \
        $(MOVE_ERR_RULE)                                               \
        exit 1;                                                        \
      fi;                                                              \
    ,                                                                  \
      $(ECHO) "Compiling file: $<";                                    \
      if ( $(COMPILE_RULE) ) ; then                                    \
        $(PRINT_ERR_TO_STDOUT)                                         \
        $(DECODE_RULE)                                                 \
        $(MOVE_OBJECT_RULE)                                            \
        $(MOVE_ERR_RULE)                                               \
      else                                                             \
        $(PRINT_ERR_TO_STDOUT)                                         \
        $(MOVE_ERR_RULE)                                               \
        exit 1;                                                        \
      fi;                                                              \
    )                                                                  \
  fi;

#-----------------------------------------------------------------------------
# implicit rule to compile a single file
# (for targets obj_path\*.obj)
#-----------------------------------------------------------------------------
$(BUILD_OBJECTS): $(OBJ_PATH)\\%.$(OBJ_SUFFIX): $(OBJ_PATH)/%.$(OBJ_SUFFIX)

#-----------------------------------------------------------------------------
# creates lib files
#-----------------------------------------------------------------------------
ifeq ($(USE_AUTOSAR_MAKE),1)
libtarget = $(sort $(foreach LIB_SRCS,$($(1)_FILES), \
                    $(ROOT)\$(GLOBAL_COMP_DIR)\$(dir $(LIB_SRCS))$(1).$(LIB_SUFFIX) \
            ))

# Copying the Libs from lib/ to component folder
copylibs:
	@$(foreach LIB,$(LIBRARIES_TO_COPY), \
  $(ECHO) "Copying lib/$(LIB).$(LIB_SUFFIX) to $(call libtarget,$(LIB))"; \
  $(call _xcopy,lib/$(LIB).$(LIB_SUFFIX),$(dir $(call libtarget,$(LIB)))) \
  )

printlibs:
	@$(ECHO) "Available libraries:"; \
  $(foreach LIB,$(LIBRARIES_TO_BUILD), \
  $(ECHO) "$(LIB)"; \
  )
endif

$(BUILD_LIBS_U): $(LIB_PATH)\\%.$(LIB_SUFFIX): $(LIB_PATH)/%.$(LIB_SUFFIX)
$(LIB_PATH)\\lib$(PROJECT_NAME).$(LIB_SUFFIX) : $(LIB_PATH)/lib$(PROJECT_NAME).$(LIB_SUFFIX)

$(LIB_PATH)/%.$(LIB_SUFFIX):
	@$(ECHO) "Creating lib: $@"; \
 if ( $(LIB_RULE) ) ; then :;  \
     $(PRINT_ERR_TO_STDOUT)    \
     $(MOVE_LIB_RULE)          \
     $(MOVE_ERR_RULE)          \
 else                          \
     $(PRINT_ERR_TO_STDOUT)    \
     $(MOVE_ERR_RULE)          \
     exit 1;                   \
 fi;

cleanlibs:
	@if [ -d $(LIB_PATH) ]; then                 \
     $(ECHO) "Deleting directory $(LIB_PATH)"; \
     $(RRM) $(LIB_PATH);                       \
 fi;                                           \
 $(MKDIR) $(LIB_PATH);

library: cleanlibs $(BUILD_LIBS_U)

#-----------------------------------------------------------------------------
# display help of implemented targets
#-----------------------------------------------------------------------------
help:
	@$(ECHO) "Call 'm' instead of make! 'm.bat' is a batch which sets the necessary";         \
 $(ECHO) "environment and calls make with the given targets.";                              \
 $(ECHO) "'m' without any targets calls 'm default'.";                                      \
 $(ECHO);                                                                                   \
 $(ECHO) "usage:";
	@$(ECHO) "m $(OBJ_PATH)\\file.$(OBJ_SUFFIX) ............. -- compile a single file";        \
 $(ECHO) "m $(LOG_PATH)\\file.c ............. -- generate single preprocessed file";        \
 $(ECHO) "m $(LOG_PATH)\\file_lint.txt ...... -- lint single file";                         \
 $(ECHO) "m default ................ -- build all targets";                                 \
 $(ECHO) "m clean .................. -- clean objects";                                     \
 $(ECHO) "m compile ................ -- compile all source files";                          \
 $(ECHO) "m depend ................. -- generate make dependencies";                        \
 $(ECHO) "m distclean .............. -- clean up for delivery";                             \
 $(ECHO) "m clean_startAppl......... -- clean up in external for startapplication delivery";\
 $(ECHO) "m pclint ................. -- run pclint for the project with 'Global Wrap-up'";  \
 $(ECHO) "m help ................... -- give help";                                         \
 $(ECHO) "m dd ..................... -- generate html deliverydescription";                 \
 $(ECHO) "m deliverydescription .... -- generate html deliverydescription";                 \
 $(ECHO) "m rebuild ................ -- make clean default";                                \
 $(ECHO) "m resource ............... -- generate resource information";                     \
 $(ECHO) "m preprocess ............. -- generate $(LOG_PATH)/file.c for whole project";     \
 $(ECHO) "m visual................   -- create Visual Studio solution";                     \
 $(ECHO) "m slick .................. -- create Visual SlickEdit project file";              \
 $(ECHO) "m slick10 ................ -- create Visual SlickEdit 10 project file";           \
 $(ECHO) "m codewright ............. -- create Codewright project space file";              \
 $(ECHO) "m doxygen ................ -- create doxygen documentation";                      \
 $(ECHO) "m qac .................... -- create QAC/MISRA check project files";              \
 $(ECHO) "m misra\*_report.txt ..... -- create QAC/MISRA report for *";                     \
 $(ECHO) "m misra\*_merge_reports .. -- create overall QAC/MISRA report for multiple configurations"; \
 $(ECHO) "m size-all ............... -- create size output for $(OBJ_PATH)\*.obj";          \
 $(ECHO) "m size-file.obj .......... -- create size output for $(OBJ_PATH)\file.obj";       \
 $(ECHO) "m $(LIB_PATH)\\libComponent.$(LIB_SUFFIX) ... -- generate a single lib file";     \
 $(ECHO) "m copylibs ............... -- copy libs in component dir";                        \
 $(ECHO) "m library ................ -- generate lib files";                                \
 $(ECHO) "m print- ................. -- display any value from a makefile variable (e.g print-COMPILER_BASE)"; \
 $(ECHO) "m inclists ............... -- print all include lists";                           \
 $(ECHO) "m buildFiles ..............-- print all source files and headers";                \
 $(ECHO) " -------- FOR NAnt support, set NANT_USED to '1' --------";                       \
 $(ECHO) "m nant [PATH] ............ -- setup NAnt + automatic rebuild with NAnt";          \
 $(ECHO) "m nant_setup [PATH]....... -- setup NAnt / update NAnt.build";                    \
 $(ECHO) "m nant_clean ............. -- clean dep/obj/err/lst files";                       \
 $(ECHO) "m nant_rm ................ -- remove NAnt configuration files ( Appl\NAnt-files ) "; \
 $(ECHO) "m nant_rm_all ............ -- remove NAnt configuration files ( Appl\NAnt-files ) and NAnt executable files ( PATH ) "; \
 $(ECHO) "m nant_help .............. -- display the NAnt-support information";

ifeq ($(USE_AUTOSAR_MAKE),1)
	@$(ECHO) "m printlibs .............. -- show a list of available libs";
endif
ifneq ($(PLATFORM_HELP),)
	@$(ECHO) "----------- platform specific targets -----------"; \
 $(PLATFORM_HELP)
endif

#-----------------------------------------------------------------------------
# pc-lint support
#-----------------------------------------------------------------------------
PCLINT_INC    = $(subst -I,-i,$(GCCINCLUDES))
PCLINT_SRC    = $(filter-out %.cpp,$(filter-out $(subst \,/,$(call toLower,PCLINT_EXCL)),$(call toLower,SOURCES_UNIX)))
PCLINT_LOGS_U = $(subst .cpp,_lint.txt,$(filter %.cpp,$(addprefix $(subst \,/,$(LOG_PATH))/,$(notdir $(PCLINT_SRC))))) \
                $(subst .c,_lint.txt,$(filter %.c,$(addprefix $(subst \,/,$(LOG_PATH))/,$(notdir $(PCLINT_SRC)))))
PCLINT_LOGS   = $(subst /,\,$(PCLINT_LOGS_U))

#-----------------------------------------------------------------------------
# Generic PCLint options valid for all PSC projects
#-----------------------------------------------------------------------------
PCLINT_OPT_GENERIC =  +v        \
                      +ffn      \
                      -hb^3     \
                      -width(0) \
                      -t2       \
                      -wlib(0)  \
                      +linebuf

pclint: pclintglobal
#pclint: pclint.lnt $(LOG_PATH) $(PCLINT_LOGS) //## Removed by Ms. If the project is linted the process is another one.

#-----------------------------------------------------------------------------
# implicit rule to lint a single file
# (for targets log_path\*_lint.txt)
#-----------------------------------------------------------------------------
$(subst /,\,$(PCLINT_LOGS)) : $(LOG_PATH)\\%_lint.txt: $(LOG_PATH)/%_lint.txt
$(LOG_PATH)/%_lint.txt: pclint.lnt force
	@$(ECHO) "Linting"                                                                        \
     $(firstword $(foreach FILE,$(filter %$*.c,$(subst .C,.c,$(PCLINT_SRC))),                     \
         $(if $(filter-out $*.c,$(notdir $(FILE))),,$(FILE))                                      \
     ))                                                                                           \
     "(-> $@)";                                                                                   \
 $(ECHO) > $(LOG_PATH)/$*_lint.txt;                                                               \
 if [ -n "$(MKVERBOSE)" ] ; then                                                                  \
     $(ECHO) $(PCLINT_UNIX)                                                                       \
         +v                                                                                       \
         $(subst ???, ,$(addprefix -d,$(foreach ITEM,$(subst \ ,???,$(PCLINT_DEF)),\"$(ITEM)\"))) \
         $(PCLINT_INC)                                                                            \
         $(PCLINT_CMD) -u                                                                         \
         $(firstword $(foreach FILE,$(filter %$*.c,$(subst .C,.c,$(PCLINT_SRC))),                 \
             $(if $(filter-out $*.c,$(notdir $(FILE))),,$(FILE))                                  \
         ));                                                                                      \
 fi;                                                                                              \
 if [ -z "$(CW_ACTIVE)" ] ; then                                                                  \
     $(PCLINT_UNIX)                                                                               \
         +v                                                                                       \
         $(subst ???, ,$(addprefix -d,$(foreach ITEM,$(subst \ ,???,$(PCLINT_DEF)),"$(ITEM)")))   \
         $(PCLINT_INC)                                                                            \
         $(PCLINT_CMD) -u                                                                         \
         $(firstword $(foreach FILE,$(filter %$*.c,$(subst .C,.c,$(PCLINT_SRC))),                 \
             $(if $(filter-out $*.c,$(notdir $(FILE))),,$(FILE))                                  \
         )) 2>/dev/null >> $@;                                                                    \
 else                                                                                             \
     $(PCLINT_UNIX)                                                                               \
         +v                                                                                       \
         $(subst ???, ,$(addprefix -d,$(foreach ITEM,$(subst \ ,???,$(PCLINT_DEF)),"$(ITEM)")))   \
         $(PCLINT_INC)                                                                            \
         $(PCLINT_CMD) -u                                                                         \
         $(firstword $(foreach FILE,$(filter %$*.c,$(subst .C,.c,$(PCLINT_SRC))),                 \
             $(if $(filter-out $*.c,$(notdir $(FILE))),,$(FILE))                                  \
         )) 2>/dev/null | $(TEE) $@;                                                              \
 fi

pclintglobal: pclint.lnt force
	@$(ECHO) "Linting the complete project, includes (Global Wrap-up)";                             \
  $(ECHO) > $(LOG_PATH)/$(PROJECT_NAME)_lint.txt;                                                 \
 if [ -n "$(MKVERBOSE)" ] ; then                                                                  \
     $(ECHO) $(PCLINT_UNIX)                                                                       \
         +v                                                                                       \
         $(subst ???, ,$(addprefix -d,$(foreach ITEM,$(subst \ ,???,$(PCLINT_DEF)),\"$(ITEM)\"))) \
         $(PCLINT_INC)                                                                            \
         $(PCLINT_CMD)                                                                            \
         $(firstword $(foreach FILE,$(filter %$*.c,$(subst .C,.c,$(PCLINT_SRC))),                 \
             $(if $(filter-out $*.c,$(notdir $(FILE))),,$(FILE))                                  \
         ));                                                                                      \
 fi;                                                                                              \
 if [ -z "$(CW_ACTIVE)" ] ; then                                                                  \
     $(PCLINT_UNIX)                                                                               \
         +v                                                                                       \
         $(subst ???, ,$(addprefix -d,$(foreach ITEM,$(subst \ ,???,$(PCLINT_DEF)),"$(ITEM)")))   \
         $(PCLINT_INC)                                                                            \
         $(PCLINT_CMD)                                                                            \
         $(foreach FILE, $(subst .C,.c,$(PCLINT_SRC)), $(FILE))                                   \
         2>/dev/null >> $(LOG_PATH)/$(PROJECT_NAME)_lint.txt;                                     \
 else                                                                                             \
     $(PCLINT_UNIX)                                                                               \
         +v                                                                                       \
         $(subst ???, ,$(addprefix -d,$(foreach ITEM,$(subst \ ,???,$(PCLINT_DEF)),"$(ITEM)")))   \
         $(PCLINT_INC)                                                                            \
         $(PCLINT_CMD)                                                                            \
         $(foreach FILE, $(subst .C,.c,$(PCLINT_SRC)), $(FILE))                                   \
         2>/dev/null | $(TEE) $(LOG_PATH)/$(PROJECT_NAME)_lint.txt;                               \
 fi

pclint.lnt:
	@$(ECHO) "Creating $@";                                                                     \
  $(ECHO) "// this file is generated automatically by MakeSupport"                            > $@; \
  $(ECHOESC) $(subst ???, ,$(foreach OPT,$(subst \ ,???,$(PCLINT_OPT_GENERIC)),'\n$(OPT)'))  >> $@; \
  $(ECHOESC) $(subst ???, ,$(foreach OPT,$(subst \ ,???,$(PCLINT_OPT_SPECIFIC)),'\n$(OPT)')) >> $@; \
  $(ECHO) "...done";                                                                                \
  $(ECHO) "";

#-----------------------------------------------------------------------------
# generate preprocess files
#-----------------------------------------------------------------------------
PREPROCESS_FILES = $(addprefix $(LOG_PATH)/,$(notdir $(filter-out %.cpp,$(call _toLower,$(SOURCES_UNIX)))))

preprocess: $(LOG_PATH) $(PREPROCESS_FILES)

$(subst /,\,$(PREPROCESS_FILES)) : $(LOG_PATH)\\%.c: $(LOG_PATH)/%.c
$(LOG_PATH)/%.c: force
	@$(ECHO) "preprocessing"                                                 \
 $(foreach FILE,$(filter %$*.c,$(subst .C,.c,$(call _toLower,$(SOURCES_UNIX)))), \
     $(if $(filter-out $*.c,$(notdir $(FILE))),,$(FILE))                         \
 )                                                                               \
 "(-> $@)";                                                                      \
 $(MAKEDEPEND) -P -C $(filter-out -M,$(CPPFLAGS)) $(GCCINCLUDES)                 \
 $(foreach FILE,$(filter %$*.c,$(subst .C,.c,$(call _toLower,$(SOURCES_UNIX)))), \
     $(if $(filter-out $*.c,$(notdir $(FILE))),,$(FILE))                         \
 ) -o $@;

##############################################################################
# File generation
##############################################################################

_CC_LC = $(strip $(if $(CC_LC),$(CC_LC),5))
_AS_LC = $(strip $(if $(AS_LC),$(AS_LC),5))
_LD_LC = $(strip $(if $(LD_LC),$(LD_LC),5))
_LB_LC = $(strip $(if $(LB_LC),$(LB_LC),5))

_CC_OFF = $(strip $(if $(CC_OFF),$(CC_OFF),1))
_AS_OFF = $(strip $(if $(AS_OFF),$(AS_OFF),1))
_LD_OFF = $(strip $(if $(LD_OFF),$(LD_OFF),1))
_LB_OFF = $(strip $(if $(LB_OFF),$(LB_OFF),1))

CC_VERSION_STRING     = $(strip $(shell $(CC_ENV_U) $(YES) $(RR_YES) | $(if $(CC),$(CC_U),$(ECHO))  $(CVERSION) 2>&1 | $(SED) $(_CC_OFF),$(_CC_LC)!d))
AS_VERSION_STRING     = $(strip $(shell $(AS_ENV_U) $(YES) $(AS_YES) | $(if $(AS),$(AS_U),$(ECHO)) $(ASVERSION) 2>&1 | $(SED) $(_AS_OFF),$(_AS_LC)!d))
LD_VERSION_STRING     = $(strip $(shell $(LD_ENV_U) $(YES) $(LD_YES) | $(if $(LD),$(LD_U),$(ECHO)) $(LDVERSION) 2>&1 | $(SED) $(_LD_OFF),$(_LD_LC)!d))
LB_VERSION_STRING     = $(strip $(shell $(LB_ENV_U) $(YES) $(LB_YES) | $(if $(LB),$(LB_U),$(ECHO)) $(LBVERSION) 2>&1 | $(SED) $(_LB_OFF),$(_LB_LC)!d))

EXT_T1_VERSION_STRING = $(strip $(shell $(EXT_T1_ENV_U) $(YES) | $(if $(EXT_T1),$(EXT_T1_U),$(ECHO)) $(EXT_T1_VERSION) 2>&1 | $(SED) $(strip $(if $(EXT_T1_LC),$(EXT_T1_LC),5))q))
EXT_T2_VERSION_STRING = $(strip $(shell $(EXT_T2_ENV_U) $(YES) | $(if $(EXT_T2),$(EXT_T2_U),$(ECHO)) $(EXT_T2_VERSION) 2>&1 | $(SED) $(strip $(if $(EXT_T2_LC),$(EXT_T2_LC),5))q))

ifeq ($(BRSVINFO_USED),1)
 $(GENDATA_DIR)\BrsVInfo.h: $(GENDATA_DIR_U)/BrsVInfo.h ;
 $(GENDATA_DIR_U)/BrsVInfo.h: Makefile     \
                            $(MAKESUPPORT_DIR)/Global.Makefile.target.make.$(VERSION)
	@$(ECHO) "Generating $@";                                                                      \
  if [ -d $(GENDATA_DIR) ] ; then :;                                                             \
  else                                                                                           \
      $(ECHO) "Creating directory $(GENDATA_DIR)";                                               \
      $(MKDIR) $(GENDATA_DIR);                                                                   \
      $(ECHO) ;                                                                                  \
  fi;                                                                                            \
  if [ -w $(GENDATA_DIR_U)/BrsVInfo.h ] || [ ! -f $(GENDATA_DIR_U)/BrsVInfo.h ]; then            \
      $(ECHO) "/* This file is generated automatically by MakeSupport */"                  > $@; \
      $(ECHO) "#ifndef __BRSVINFO_H"                                                      >> $@; \
      $(ECHO) "#define __BRSVINFO_H"                                                      >> $@; \
      $(ECHO)                                                                             >> $@; \
      $(ECHO) "#ifndef _BRS_V_INFO_VALID"                                                 >> $@; \
      $(ECHO) "  #error Include of BrsVInfo.h is only allowed in context of BrsCtrl.c"    >> $@; \
      $(ECHO) "#endif"                                                                    >> $@; \
      $(ECHO)                                                                             >> $@; \
      $(ECHO) "#ifndef _BRS_ENABLE_FLAG_ACCESS_"                                          >> $@; \
      $(ECHO) "  #define _BRS_ENABLE_FLAG_ACCESS_"                                        >> $@; \
      $(ECHO) "#endif"                                                                    >> $@; \
      $(ECHO)                                                                             >> $@; \
      $(ECHO) "#if defined ( C_COMP_IAR_M16C )"                                           >> $@; \
      $(ECHO) "  #if defined ( _NEAR_ )"                                                  >> $@; \
      $(ECHO) "  /* Set const data to const segment, don\'t initialize */"                >> $@; \
      $(ECHO) "  #pragma memory=constseg(CONST_DATA) :far"                                >> $@; \
      $(ECHO) "  #endif"                                                                  >> $@; \
      $(ECHO) "#endif"                                                                    >> $@; \
      $(ECHO)                                                                             >> $@; \
      if [ -n '$(CC)' ]; then $(ECHO) "#define BRS_ENABLE_COMPILER_VERSION"           >> $@; fi; \
      if [ -n '$(MA)' ]; then $(ECHO) "#define BRS_ENABLE_MACROASSEMBLER_VERSION"     >> $@; fi; \
      if [ -n '$(AS)' ]; then $(ECHO) "#define BRS_ENABLE_ASSEMBLER_VERSION"          >> $@; fi; \
      if [ -n '$(LD)' ]; then $(ECHO) "#define BRS_ENABLE_LINKER_VERSION"             >> $@; fi; \
      if [ -n '$(LB)' ]; then $(ECHO) "#define BRS_ENABLE_LIBRARIAN_VERSION"          >> $@; fi; \
      if [ -n '$(EXT_T1)' ]; then $(ECHO) "#define BRS_ENABLE_EXT_T1_VERSION"         >> $@; fi; \
      if [ -n '$(EXT_T2)' ]; then $(ECHO) "#define BRS_ENABLE_EXT_T2_VERSION"         >> $@; fi; \
      $(ECHO)                                                                             >> $@; \
      $(ECHO) "#if defined ( BRS_ENABLE_TOOL_VERSIONINFO )"                               >> $@; \
      $(ECHO)                                                                             >> $@; \
      if [ -n '$(CC)' ]; then                                                                    \
          $(ECHO) "    retrieving Compiler Version";                                             \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsCompilerVersion[] ='                 \
                         '"$(subst \,\\,$(CC_VERSION_STRING))";'                          >> $@; \
          $(ECHO) "#if defined ( BRS_ENABLE_FLAG_ACCESS )"                                >> $@; \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsCompilerAdditional[] ='              \
                         '"$(subst ",\",$(subst \,\\,$(CFLAGS)))";'                       >> $@; \
          $(ECHO) "#endif /* defined ( BRS_ENABLE_FLAG_ACCESS ) */"                       >> $@; \
          $(ECHO)                                                                         >> $@; \
      fi;                                                                                        \
      if [ -n '$(AS)' ]; then                                                                    \
          $(ECHO) "    retrieving Assembler Version";                                            \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsAssemblerVersion[] ='                \
                         '"$(subst \,\\,$(AS_VERSION_STRING))";'                          >> $@; \
          $(ECHO) "#if defined ( BRS_ENABLE_FLAG_ACCESS )"                                >> $@; \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsAssemblerAdditional[] ='             \
                         '"$(subst ",\",$(subst \,\\,$(ASFLAGS)))";'                      >> $@; \
          $(ECHO) "#endif /* defined ( BRS_ENABLE_FLAG_ACCESS ) */"                       >> $@; \
          $(ECHO)                                                                         >> $@; \
      fi;                                                                                        \
      if [ -n '$(LD)' ]; then                                                                    \
          $(ECHO) "    retrieving Linker Version";                                               \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsLinkerVersion[] ='                   \
                         '"$(subst \,\\,$(LD_VERSION_STRING))";'                          >> $@; \
          $(ECHO) "#if defined ( BRS_ENABLE_FLAG_ACCESS )"                                >> $@; \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsLinkerAdditional[] ='                \
                         '"$(subst ",\",$(subst \,\\,$(LDFLAGS)))";'                      >> $@; \
          $(ECHO) "#endif /* defined ( BRS_ENABLE_FLAG_ACCESS ) */"                       >> $@; \
          $(ECHO)                                                                         >> $@; \
      fi;                                                                                        \
      if [ -n '$(LB)' ]; then                                                                    \
          $(ECHO) "    retrieving Librarian Version";                                            \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsLibrarianVersion[] ='                \
                         '"$(subst \,\\,$(LB_VERSION_STRING))";'                          >> $@; \
          $(ECHO) "#if defined ( BRS_ENABLE_FLAG_ACCESS )"                                >> $@; \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsLibrarianParameter[] ='              \
                         '"$(subst ",\",$(subst \,\\,$(LBFLAGS)))";'                      >> $@; \
          $(ECHO) "#endif /* defined ( BRS_ENABLE_FLAG_ACCESS ) */"                       >> $@; \
          $(ECHO)                                                                         >> $@; \
      fi;                                                                                        \
      if [ -n '$(EXT_T1)' ]; then                                                                \
          $(ECHO) "    retrieving External Tool 1 Version";                                      \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsExtTool1Version[] ='                 \
                         '"$(subst \,\\,$(EXT_T1_VERSION_STRING))";'                      >> $@; \
          $(ECHO) "#if defined ( BRS_ENABLE_FLAG_ACCESS )"                                >> $@; \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsExtTool1Parameter[] ='               \
                         '"$(subst ",\",$(subst \,\\,$(EXT_T1_FLAGS)))";'                 >> $@; \
          $(ECHO) "#endif /* defined ( BRS_ENABLE_FLAG_ACCESS ) */"                       >> $@; \
          $(ECHO)                                                                         >> $@; \
      fi;                                                                                        \
      if [ -n '$(EXT_T2)' ]; then                                                                \
          $(ECHO) "    retrieving External Tool 2 Version";                                      \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsExtTool2Version[] ='                 \
                         '"$(subst \,\\,$(EXT_T2_VERSION_STRING))";'                      >> $@; \
          $(ECHO) "#if defined ( BRS_ENABLE_FLAG_ACCESS )"                                >> $@; \
          $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsExtTool2Parameter[] ='               \
                         '"$(subst ",\",$(subst \,\\,$(EXT_T2_FLAGS)))";'                 >> $@; \
          $(ECHO) "#endif /* defined ( BRS_ENABLE_FLAG_ACCESS ) */"                       >> $@; \
          $(ECHO)                                                                         >> $@; \
      fi;                                                                                        \
      $(ECHO) "#endif /* defined ( BRS_ENABLE_TOOL_VERSIONINFO ) */"                      >> $@; \
      $(ECHO)                                                                             >> $@; \
      $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsCompilerDef[]   = "$(COMPILER_MANUFACTURER)";'\
                                                                                          >> $@; \
      $(ECHO) 'V_MEMROM0 V_MEMROM1 vsint8 V_MEMROM2 kBrsControllerDef[] = "$(DERIVATIVE)";'      \
                                                                                          >> $@; \
      $(ECHO)                                                                             >> $@; \
      $(ECHO) "#if defined ( C_COMP_IAR_M16C )"                                           >> $@; \
      $(ECHO) "  #if defined ( _NEAR_ )"                                                  >> $@; \
      $(ECHO) "  /* Normal segment usage */"                                              >> $@; \
      $(ECHO) "  #pragma memory=default"                                                  >> $@; \
      $(ECHO) "  #endif"                                                                  >> $@; \
      $(ECHO) "#endif"                                                                    >> $@; \
      $(ECHO)                                                                             >> $@; \
      $(ECHO) "#endif /* __BRSVINFO_H */"                                                 >> $@; \
  else                                                                                           \
      $(ECHO) ;                                                                                  \
      $(ECHO) "Couldn't generate BrsVInfo.h.";                                                   \
      $(ECHO) "File is write protected!";                                                        \
      $(ECHO) ;                                                                                  \
  fi;                                                                                            \
  $(ECHO) "...done";                                                                             \
  $(ECHO) ;
endif

##############################################################################
# CodeWright Workarounds
##############################################################################

ifneq ($(CW_ACTIVE),)
    #-----------------------------------------------------------------------------
    # implicit rule to lint a single file (workaround for CodeWright)
    # as CodeWright does not have a filename component macro for only the basename
    # of a file without the path and without the suffix
    # (for targets log_path\*.c_lint.txt)
    #-----------------------------------------------------------------------------
    $(subst _lint.txt,.c_lint.txt,$(subst /,\,$(PCLINT_LOGS))) : $(LOG_PATH)\\%.c_lint.txt: $(LOG_PATH)/%_lint.txt

    #-----------------------------------------------------------------------------
    # implicit rule to compile a single file (workaround for CodeWright)
    # as CodeWright does not have a filename component macro for only the basename
    # of a file without the path and without the suffix
    # (for targets log_path\*.c_.obj)
    #-----------------------------------------------------------------------------
    $(subst .$(OBJ_SUFFIX),.c.$(OBJ_SUFFIX),$(OBJECTS)): $(OBJ_PATH)\\%.c.$(OBJ_SUFFIX): $(OBJ_PATH)/%.$(OBJ_SUFFIX)
    $(subst .$(OBJ_SUFFIX),.$(ASM_SUFFIX).$(OBJ_SUFFIX),$(OBJECTS)): $(OBJ_PATH)\\%.$(ASM_SUFFIX).$(OBJ_SUFFIX): $(OBJ_PATH)/%.$(OBJ_SUFFIX)
endif

##############################################################################
# Project File Generation
##############################################################################

#-----------------------------------------------------------------------------
# $(INCFILE_LIST) contains a list of all include files the current project
# depends on (in lower case characters).
#-----------------------------------------------------------------------------
INCFILE_LIST =                       \
  $(subst ???,\ ,                    \
    $(sort                           \
      $(call _toLower,               \
        $(sort                       \
          $(subst /,\,               \
            $(subst \ ,???,          \
              $(shell                \
                $(SED)               \
                's/\\ /\?\?\?/g;     \
                 s!\\$$!!g;          \
                 s!\\!/!g;           \
                 /Makefile.config/d; \
                 s/[^ ]*\.\(cpp\|cfg\|c\|$(OBJ_SUFFIX)\|$(LIB_SUFFIX)\|$(ASM_SUFFIX)\):\{0,1\}//gI;  \
                 /^\#/d'             \
                $(PROJECT_NAME).dep  \
              )                      \
            )                        \
          )                          \
        )                            \
      )                              \
    )                                \
  )

INCFILE_LIST_UNIX = $(subst ???,\ ,$(subst \,/,$(subst \ ,???,$(INCFILE_LIST))))

INCDIR_LIST  = $(subst ???,\ ,$(sort $(subst \ , ,$(subst \���,,$(dir $(subst \ ,???,$(INCFILE_LIST)))���))))

#-----------------------------------------------------------------------------
# $(compName) contains the name of the component which is used
#-----------------------------------------------------------------------------
ifeq ($(USE_AUTOSAR_MAKE),1)
compName = $(call asrName,$(1))
else
compName = $(1)
endif
#-----------------------------------------------------------------------------
# List of all the files which belong to the MakeSupport and can be modified
# $(MAKESUPPORT_LIST_SEP) - same separated by semicolon
#-----------------------------------------------------------------------------
MAKESUPPORT_LIST = Makefile                                                       \
                   $(PROJECT_NAME).dep                                            \
                   $(MAKEFILE_CONFIG)                                             \
                   Makefile.project.part.defines                                  \
                   Makefile.$(PLATFORM).$(COMPILER_MANUFACTURER).$(EMULATOR).make \
                   pclint.lnt                                                     \
                   m.bat                                                          \
                   b.bat

MAKESUPPORT_LIST_SEP = $(strip $(call separatedList,MAKESUPPORT_LIST,_SEMI_COLON))

MAKEFILE_CONFIG = $(shell if [ -f Makefile.config ] ; then $(ECHO) Makefile.config; fi)

#-----------------------------------------------------------------------------
# List of all possible 'wildcarded' error, list and map files
# $(XXX_SEP) - same separated by semicolon
# $(XXX_WOP) - without path
#-----------------------------------------------------------------------------
ERR_LIST               = $(addprefix $(ERR_PATH)\*.,$(ERR_SUFFIX_LIST))
ERR_LIST_SEP           = $(strip $(call separatedList,ERR_LIST,_SEMI_COLON))
LST_N_MAP_LIST         = $(addprefix $(LST_PATH)\*.,$(LST_SUFFIX_LIST)) $(PROJECT_NAME).map
LST_N_MAP_LIST_SEP     = $(strip $(call separatedList,LST_N_MAP_LIST,_SEMI_COLON))

ERR_LIST_WOP           = $(addprefix *.,$(ERR_SUFFIX_LIST))
ERR_LIST_SEP_WOP       = $(strip $(call separatedList,ERR_LIST_WOP,_SEMI_COLON))
LST_N_MAP_LIST_WOP     = $(addprefix *.,$(LST_SUFFIX_LIST)) $(PROJECT_NAME).map
LST_N_MAP_LIST_SEP_WOP = $(strip $(call separatedList,LST_N_MAP_LIST_WOP,_SEMI_COLON))

#-----------------------------------------------------------------------------
# create Microsoft Visual Studio Solution
#-----------------------------------------------------------------------------

PREPROC_DEFS = $(patsubst -D%,%,$(filter $(CDEF)%,$(CFLAGS)))

#-----------------------------------------------------------------------------
# create Microsoft Visual Studio 2013 Solution
#-----------------------------------------------------------------------------

visual: VS_$(PROJECT_NAME).sln VS_$(PROJECT_NAME).vcxproj.users VS_$(PROJECT_NAME).vcxproj.filters VS_$(PROJECT_NAME).vcxproj VS_$(PROJECT_NAME).props

visual10: visual
visual12: visual

#---------------------------------------------------------------------------------------------------------------- 
# .sln
#---------------------------------------------------------------------------------------------------------------- 
VS_$(PROJECT_NAME).sln: force
	@$(ECHO) "Generating Microsoft Visual Studio Solution File: $@ ...";                                  \
  $(ECHO) 'Microsoft Visual Studio Solution File, Format Version 12.00'                             > $@; \
  $(ECHO) '# Visual C++ Express 2013'                                                              >> $@; \
  $(ECHO) 'Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "$(PROJECT_NAME)", "VS_$(PROJECT_NAME).vcxproj", "{665AAE83-81C0-DC97-5FEF-44F6E06327CC}"' >> $@; \
  $(ECHO) 'EndProject'                                                                             >> $@; \
  $(ECHO) 'Global'                                                                                 >> $@; \
  $(ECHO) '	GlobalSection(SolutionConfigurationPlatforms) = preSolution'                           >> $@; \
  $(ECHO) '		Debug|Win32 = Debug|Win32'                                                           >> $@; \
  $(ECHO) '		Release|Win32 = Release|Win32'                                                       >> $@; \
  $(ECHO) '	EndGlobalSection'                                                                      >> $@; \
  $(ECHO) '	GlobalSection(ProjectConfigurationPlatforms) = postSolution'                           >> $@; \
  $(ECHO) '		{665AAE83-81C0-DC97-5FEF-44F6E06327CC}.Debug|Win32.ActiveCfg = Debug|Win32'          >> $@; \
  $(ECHO) '		{665AAE83-81C0-DC97-5FEF-44F6E06327CC}.Debug|Win32.Build.0 = Debug|Win32'            >> $@; \
  $(ECHO) '		{665AAE83-81C0-DC97-5FEF-44F6E06327CC}.Release|Win32.ActiveCfg = Release|Win32'          >> $@; \
  $(ECHO) '		{665AAE83-81C0-DC97-5FEF-44F6E06327CC}.Release|Win32.Build.0 = Release|Win32'            >> $@; \
  $(ECHO) '	EndGlobalSection'                                                                      >> $@; \
  $(ECHO) '	GlobalSection(SolutionProperties) = preSolution'                                       >> $@; \
  $(ECHO) '		HideSolutionNode = FALSE'                                                            >> $@; \
  $(ECHO) '	EndGlobalSection'                                                                      >> $@; \
  $(ECHO) 'EndGlobal'                                                                              >> $@; \
  $(ECHO) "...done";                                                                                      \
  $(ECHO) "";

#---------------------------------------------------------------------------------------------------------------- 
# vcxproj.users
#---------------------------------------------------------------------------------------------------------------- 
VS_$(PROJECT_NAME).vcxproj.users: force
	@$(ECHO) "Generating Microsoft Visual Studio User Project File: $@ ...";                                  \
  $(ECHO) '<?xml version="1.0" encoding="utf-8"?>'                                                      > $@; \
  $(ECHO) '<Project  xmlns="http://schemas.microsoft.com/developer/msbuild/2003">'   >> $@; \
  $(ECHO) '</Project>'                                                                                 >> $@; \
  $(ECHO) "...done";                                                                                          \
  $(ECHO) "";
  
#---------------------------------------------------------------------------------------------------------------- 
# vcxproj.filters
#---------------------------------------------------------------------------------------------------------------- 
ifneq ($(PLATFORM),CANOE)
VS_$(PROJECT_NAME).vcxproj.filters: force
	@$(ECHO) "Generating Microsoft Visual Studio Filter Project File: $@ ...";                                  \
  $(ECHO) '<?xml version="1.0" encoding="utf-8"?>'                                                        > $@; \
  $(ECHO) '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">'                        >> $@; \
  $(ECHO) '  <ItemGroup>'                                                                                >> $@; \
  $(ECHO) '    <Filter Include="Source">'                                                                >> $@; \
  $(ECHO) '      <Extensions>c;cpp;def;bat</Extensions>'                                                 >> $@; \
  $(ECHO) '    </Filter>'                                                                                >> $@; \
  $(ECHO) '    <Filter Include="Header">'                                                                >> $@; \
  $(ECHO) '      <Extensions>h</Extensions>'                                                             >> $@; \
  $(ECHO) '    </Filter>'                                                                                >> $@; \
  $(ECHO) '    <Filter Include="BswStatic">'                                                             >> $@; \
  $(ECHO) '      <Extensions>c;h</Extensions>'                                                           >> $@; \
  $(ECHO) '    </Filter>'                                                                                >> $@; \
  $(ECHO) '    <Filter Include="ThirdParty">'                                                            >> $@; \
  $(ECHO) '      <Extensions>c;h</Extensions>'                                                 >> $@; \
  $(ECHO) '    </Filter>'                                                                                >> $@; \
  $(ECHO) '    <Filter Include="GenData">'                                                               >> $@; \
  $(ECHO) '      <Extensions>c;h</Extensions>'                                               >> $@; \
  $(ECHO) '    </Filter>'                                                                                >> $@; \
  $(ECHO) '    <Filter Include="Compiler">'                                                               >> $@; \
  $(ECHO) '      <Extensions>c;h</Extensions>'                                               >> $@; \
  $(ECHO) '    </Filter>'                                                                                >> $@; \
  $(ECHO) '    <Filter Include="MakeSupport">'                                                           >> $@; \
  $(ECHO) '      <Extensions>make;bat;dep;config;defines;lnt</Extensions>'                               >> $@; \
  $(ECHO) '    </Filter>'                                                                                >> $@; \
  $(ECHO) '    <Filter Include="Error Files">'                                                           >> $@; \
  $(ECHO) '      <Extensions>err</Extensions>'                                                           >> $@; \
  $(ECHO) '    </Filter>'                                                                                >> $@; \
  $(ECHO) '    <Filter Include="List and Map Files">'                                                    >> $@; \
  $(ECHO) '      <Extensions>map;lst</Extensions>'                                                       >> $@; \
  $(ECHO) '    </Filter>'                                                                                >> $@; \
  $(ECHO) '    <Filter Include="PCLint Files">'                                                          >> $@; \
  $(ECHO) '      <Extensions>txt</Extensions>'                                                           >> $@; \
  $(ECHO) '    </Filter>'                                                                                >> $@; \
  $(ECHO) '  </ItemGroup>'                                                                               >> $@; \
  $(ECHO) '  <ItemGroup><!-- Static Files -->'                                                           >> $@; \
  $(foreach SRC,$(subst /,\,$(filter-out $(ROOT)\$(if $(GLOBAL_COMP_DIR),$(GLOBAL_COMP_DIR)\,)$(GLOBAL_THIRDPARTY_DIR)%,$(MODULE_SOURCE_LST))),\
    $(ECHO) '    <ClCompile Include="$(SRC)"><Filter>BswStatic</Filter></ClCompile>'                     >> $@;)\
  $(foreach INC,$(subst /,\,$(filter-out $(ROOT)\$(if $(GLOBAL_COMP_DIR),$(GLOBAL_COMP_DIR)\,)$(GLOBAL_THIRDPARTY_DIR)%,$(MODULE_HEADER_LST))),\
    $(ECHO) '    <ClInclude Include="$(INC)"><Filter>BswStatic</Filter></ClInclude>'                     >> $@;)\
  $(ECHO) '  </ItemGroup>'                                                                               >> $@; \
  $(ECHO) '  <ItemGroup><!-- Generated Files -->'                                                        >> $@; \
  $(foreach SRC,$(subst /,\,$(sort $(DATA_SOURCE_LST) $(MODULE_DATA_LST) $(MODULE_COMMON_LST))),\
    $(ECHO) '    <ClCompile Include="$(SRC)"><Filter>GenData</Filter></ClCompile>'                       >> $@;)\
  $(foreach INC,$(subst /,\,$(GEN_HEADERS)),\
    $(ECHO) '    <ClInclude Include="$(INC)"><Filter>Gendata</Filter></ClInclude>'                       >> $@;)\
  $(ECHO) '  </ItemGroup>'                                                                               >> $@; \
  $(ECHO) '  <ItemGroup><!-- Third Party Files -->'                                                      >> $@; \
  $(foreach SRC,$(THIRD_PARTY_SOURCES),\
    $(ECHO) '    <ClCompile Include="$(SRC)"><Filter>ThirdParty</Filter></ClCompile>'                    >> $@;)\
  $(foreach INC,$(THIRD_PARTY_HEADERS),\
    $(ECHO) '    <ClInclude Include="$(INC)"><Filter>ThirdParty</Filter></ClInclude>'                    >> $@;)\
  $(ECHO) '  </ItemGroup>'                                                                               >> $@; \
  $(ECHO) '  <ItemGroup><!-- Compiler Files -->'                                                         >> $@; \
  $(foreach SRC,$(COMPILER_SOURCES),\
    $(ECHO) '    <ClCompile Include="$(SRC)"><Filter>Compiler</Filter></ClCompile>'                      >> $@;)\
   $(foreach INC,$(COMPILER_HEADERS),\
    $(ECHO) '    <ClInclude Include="$(INC)"><Filter>Compiler</Filter></ClInclude>'                      >> $@;)\
  $(ECHO) '  </ItemGroup>'                                                                               >> $@; \
  $(ECHO) '  <ItemGroup>'                                                                                >> $@; \
  $(foreach SRC,$(subst /,\,$(MAKESUPPORT_LIST)),\
    $(ECHO) '    <None Include="$(SRC)"><Filter>MakeSupport</Filter></None>'                             >> $@;)\
  $(ECHO) '  </ItemGroup>'                                                                               >> $@; \
  $(ECHO) '</Project>'                                                                                   >> $@; \
  $(ECHO) "...done";                                                                                            \
  $(ECHO) "";

#---------------------------------------------------------------------------------------------------------------- 
# vcxproj
#---------------------------------------------------------------------------------------------------------------- 
VS_$(PROJECT_NAME).vcxproj: force
	@$(ECHO) "Generating Microsoft Visual Studio Project File: $@ ...";                                           \
   $(ECHO) '<?xml version="1.0" encoding="utf-8"?>'                                                       > $@; \
   $(ECHO) '<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' >> $@; \
   $(ECHO) '  <ItemGroup Label="ProjectConfigurations">'                                                 >> $@; \
   $(ECHO) '    <ProjectConfiguration Include="Debug|Win32">'                                            >> $@; \
   $(ECHO) '      <Configuration>Debug</Configuration>'                                                  >> $@; \
   $(ECHO) '      <Platform>Win32</Platform>'                                                            >> $@; \
   $(ECHO) '    </ProjectConfiguration>'                                                                 >> $@; \
   $(ECHO) '  </ItemGroup>'                                                                              >> $@; \
   $(ECHO) '  <PropertyGroup Label="Globals">'                                                           >> $@; \
   $(ECHO) '    <ProjectName>$(PROJECT_NAME)</ProjectName>'                                              >> $@; \
   $(ECHO) '  </PropertyGroup>'                                                                          >> $@; \
   $(ECHO) '  <Import Project="$$(VCTargetsPath)\Microsoft.Cpp.Default.props" />'                        >> $@; \
   $(ECHO) "  <PropertyGroup Condition=\"'"'$$(Configuration)|$$(Platform)'"'=='Debug|Win32'\" Label=\"Configuration\">" >> $@; \
   $(ECHO) '    <ConfigurationType>Makefile</ConfigurationType>'                                         >> $@; \
   $(ECHO) '  </PropertyGroup>'                                                                          >> $@; \
   $(ECHO) '  <Import Project="$$(VCTargetsPath)\Microsoft.Cpp.props" />'                                >> $@; \
   $(ECHO) '  <ImportGroup Label="ExtensionSettings">'                                                   >> $@; \
   $(ECHO) '  </ImportGroup>'                                                                            >> $@; \
   $(ECHO) "  <ImportGroup Condition=\"'"'$$(Configuration)|$$(Platform)'"'=='Debug|Win32'\" Label=\"PropertySheets\">" >> $@; \
   $(ECHO) "    <Import Project=\""'$$(UserRootDir)'"\Microsoft.Cpp."'$$(Platform)'".user.props\" Condition=\"exists('"'$$(UserRootDir)'"\Microsoft.Cpp."'$$(Platform)'".user.props')\" Label=\"LocalAppDataPlatform\" />" >> $@; \
   $(ECHO) "    <Import Project=\"VS_$(PROJECT_NAME).props\"/>"                                          >> $@; \
   $(ECHO) '  </ImportGroup>'                                                                            >> $@; \
   $(ECHO) '  <PropertyGroup Label="UserMacros" />'                                                      >> $@; \
   $(ECHO) '  <PropertyGroup>'                                                                           >> $@; \
   $(ECHO) '    <_ProjectFileVersion>12.0.21005.1</_ProjectFileVersion>'                                 >> $@; \
   $(ECHO) "    <OutDir Condition=\"'"'$$(Configuration)|$$(Platform)'"'=='Debug|Win32'\">.\obj\</OutDir>" >> $@; \
   $(ECHO) "    <IntDir Condition=\"'"'$$(Configuration)|$$(Platform)'"'=='Debug|Win32'\">.\obj\</IntDir>" >> $@; \
   $(ECHO) "    <NMakeBuildCommandLine Condition=\"'"'$$(Configuration)|$$(Platform)'"'=='Debug|Win32'\">set ERR_TO_STDOUT=1 "'&amp;&amp; m.bat</NMakeBuildCommandLine>'             >> $@; \
   $(ECHO) "    <NMakeReBuildCommandLine Condition=\"'"'$$(Configuration)|$$(Platform)'"'=='Debug|Win32'\">set ERR_TO_STDOUT=1 "'&amp;&amp; m.bat rebuild</NMakeReBuildCommandLine>' >> $@; \
   $(ECHO) "    <NMakeCleanCommandLine Condition=\"'"'$$(Configuration)|$$(Platform)'"'=='Debug|Win32'\">set ERR_TO_STDOUT=1 "'&amp;&amp; m.bat clean</NMakeCleanCommandLine>'       >> $@; \
   $(ECHO) "    <NMakeOutput Condition=\"'"'$$(Configuration)|$$(Platform)'"'=='Debug|Win32'\">$(PROJECT_NAME).$(BINARY_SUFFIX)</NMakeOutput>"                                       >> $@; \
   $(ECHO) "    <NMakeIncludeSearchPath Condition=\"'"'$$(Configuration)|$$(Platform)'"'=='Debug|Win32'\">" >> $@;\
   $(foreach INC,$(INC_LIST),\
     $(ECHO)  '    $(INC);' >> $@;)\
   $(ECHO) "    </NMakeIncludeSearchPath>"                                                               >> $@; \
   $(ECHO) '  </PropertyGroup>'                                                                          >> $@; \
   $(ECHO) '  <ItemDefinitionGroup>'                                                                     >> $@; \
   $(ECHO) '  </ItemDefinitionGroup>'                                                                    >> $@; \
   $(ECHO) '  <ItemGroup>'                                                                               >> $@; \
   $(foreach SRC,$(MODULE_SOURCE_LST),                                                                          \
     $(ECHO)  '    <ClCompile Include="$(subst /,\,$(SRC))" />' >> $@;)\
   $(foreach SRC,$(DATA_SOURCE_LST) $(MODULE_DATA_LST) $(MODULE_COMMON_LST) $(APP_SOURCE_LST),                  \
     $(ECHO)  '    <ClCompile Include="$(subst /,\,$(SRC))"/>' >> $@;)\
   $(ECHO) '  </ItemGroup>'                                                                              >> $@; \
   $(ECHO) '  <ItemGroup>'                                                                               >> $@; \
   $(foreach SRC,$(MAKESUPPORT_LIST),                                                                           \
     $(ECHO) '    <None Include="$(SRC)"/>' >> $@;)\
   $(foreach SRC, $(foreach SFX, $(ERR_SUFFIX_LIST),                                                            \
                 $(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%.$(SFX),$(BUILD_OBJECTS))),                           \
     $(ECHO) '    <None Include="$(ERR_PATH)\$(SRC)"/>' >> $@;)\
   if [ $(ERR_OUTPUT)=="PIPE" ] ; then                                                                          \
     $(ECHO) '    <None Include="$(ERR_PATH)\$(PROJECT_NAME).$(ERR_SUFFIX)" />'                          >> $@; \
   fi;                                                                                                          \
   $(foreach SRC, $(foreach SFX, $(LST_SUFFIX_LIST),                                                            \
                 $(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%.$(SFX),$(BUILD_OBJECTS))),                           \
     $(ECHO) '    <None Include="$(LST_PATH)\$(SRC)"/>' >> $@;)\
   $(ECHO)   '    <None Include="$(PROJECT_NAME).map"/>'                                                 >> $@; \
   $(foreach SRC,                                                                                               \
                $(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%_lint.txt,$(BUILD_OBJECTS)),                           \
     $(ECHO) '    <None Include="$(LOG_PATH)\$(SRC)"/>' >> $@;)\
   $(ECHO) '  </ItemGroup>'                                                                              >> $@; \
   $(ECHO) '  <ItemGroup>'                                                                               >> $@; \
   $(foreach FILE,$(HEADERS),\
     $(ECHO) '    <ClInclude Include="$(FILE)"/>' >> $@;)\
   $(ECHO) '  </ItemGroup>'                                                                              >> $@; \
   $(ECHO) '  <Import Project="$$(VCTargetsPath)\Microsoft.Cpp.targets"/>'                               >> $@; \
   $(ECHO) '  <ImportGroup Label="ExtensionTargets">'                                                    >> $@; \
   $(ECHO) '  </ImportGroup>'                                                                            >> $@; \
   $(ECHO) '</Project>   '                                                                               >> $@; \
   $(ECHO) "...done";                                                                                           \
   $(ECHO) "";
endif

#---------------------------------------------------------------------------------------------------------------- 
# props
#---------------------------------------------------------------------------------------------------------------- 
VS_$(PROJECT_NAME).props: force
	@$(ECHO) "Generating Microsoft Visual Studio Project Properties File: $@ ...";                                 \
   $(ECHO) '<?xml version="1.0" encoding="utf-8"?>'                                                        > $@; \
   $(ECHO) '  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">'                      >> $@; \
   $(ECHO) '    <ImportGroup Label="PropertySheets" />'                                                   >> $@; \
   $(ECHO) '   <PropertyGroup Label="UserMacros" />'                                                      >> $@; \
   $(ECHO) '    <PropertyGroup>'                                                                          >> $@; \
   $(ECHO) '      <NMakeIncludeSearchPath>'                                                               >> $@; \
   $(foreach INC,$(INC_LIST),\
     $(ECHO)  '$(INC);' >> $@;)\
   $(ECHO) '      </NMakeIncludeSearchPath>'                                                              >> $@; \
   $(ECHO) '      <NMakePreprocessorDefinitions>'                                                         >> $@; \
   $(ECHOESC) '$(foreach BRSDEF,$(PREPROC_DEFS),$(BRSDEF);)'                                              >> $@; \
   $(ECHO) '      </NMakePreprocessorDefinitions>'                                                        >> $@; \
   $(ECHO) '    </PropertyGroup>'                                                                         >> $@; \
   $(ECHO) '    <ItemDefinitionGroup />'                                                                  >> $@; \
   $(ECHO) '    <ItemGroup />'                                                                            >> $@; \
   $(ECHO) '  </Project>'                                                                                 >> $@; \
   $(ECHO) "...done";                                                                                            \
   $(ECHO) "";

#-----------------------------------------------------------------------------
# SlickeEdit project file
#-----------------------------------------------------------------------------
slick: $(PROJECT_NAME).vpj $(PROJECT_NAME).vpw

$(PROJECT_NAME).vpw: force
	@$(ECHO) "Generating SlickEdit Workspace: $(PROJECT_NAME).vpw ..."; \
 $(ECHO) "[CurrentProject]"                                           > $@; \
 $(ECHO) "curproj=$(subst \,\\,$(CURDIR)\$(PROJECT_NAME)).vpj"       >> $@; \
 $(ECHO) "[ProjectFiles]"                                            >> $@; \
 $(ECHO) "$(PROJECT_NAME).vpj"                                       >> $@; \
 $(ECHO) "[State]"                                                   >> $@; \
 $(ECHO) "CWD: $(subst \,\\,$(CURDIR))"                              >> $@; \
 $(ECHO) "...done";                                                         \
 $(ECHO) "";

$(PROJECT_NAME).vpj: force
	@$(ECHO) "Generating SlickEdit Project File: $(PROJECT_NAME).vpj ...";                                                              \
 $(ECHO) "[COMPILER]"                                                                                                                 > $@; \
 $(ECHO) "version=5.0"                                                                                                               >> $@; \
 $(ECHO) "compile=concur|capture|hide|clear|savecurrent|:Compile:&Compile,set ERR_TO_STDOUT=1 && m.bat $(OBJ_PATH)\%n.$(OBJ_SUFFIX)" >> $@; \
 $(ECHO) "make=concur|capture|hide|clear|saveall|:Build:&Build,set ERR_TO_STDOUT=1 && m.bat"                                         >> $@; \
 $(ECHO) "rebuild=concur|capture|hide|clear|saveall|:Rebuild:&Rebuild,set ERR_TO_STDOUT=1 && b.bat"                                  >> $@; \
 $(ECHO) "debug=hide|:Debug:&Debug,"                                                                                                 >> $@; \
 $(ECHO) "execute=hide|:Execute:E&xecute,"                                                                                           >> $@; \
 $(ECHO) "user1=hide|:User 1:User 1,"                                                                                                >> $@; \
 $(ECHO) "user2=hide|:User 2:User 2,"                                                                                                >> $@; \
 $(ECHO) "usertool_clean=concur|capture|hide|clear|saveall|:Clean:&Clean,m.bat clean"                                                >> $@; \
 $(ECHO) "usertool_pclint=concur|capture|hide|clear|saveall|:PCLint:&PCLint,m.bat $(LOG_PATH)\%n_lint.txt"                           >> $@; \
 $(ECHO) "usertool_pclint_all=concur|capture|hide|clear|saveall|:PCLintAll:&PCLintAll,m.bat pclint"                                  >> $@; \
 $(ECHO) "usertool_preprocess=concur|capture|hide|clear|saveall|:PreProcess:&PreProcess,m.bat  $(LOG_PATH)\%n.%e"                    >> $@; \
 $(ECHO) "usertool_depend=concur|capture|hide|clear|saveall|:Depend:&Depend,m.bat depend"                                            >> $@; \
 $(ECHO) "usertool_version=concur|capture|hide|clear|saveall|:Version:&Version,m.bat version"                                        >> $@; \
 $(ECHO) "usertool_doxygen=concur|capture|hide|clear|saveall|:Doxygen:&Doxygen,m.bat doxygen"                                        >> $@; \
 $(ECHO) "workingdir=."                                                                                                              >> $@; \
 $(ECHO) "includedirs=$(subst -I,,$(subst \,\\,$(GCCINCLUDES)))"                                                                     >> $@; \
 $(ECHO) "reffile="                                                                                                                  >> $@; \
 $(ECHO) "MACRO=\\n"                                                                                                                 >> $@; \
 $(ECHO) "FILTERPATTERN=*.c\\n*.h\\n$(MAKESUPPORT_LIST_SEP)\\n$(ERR_LIST_SEP_WOP)\\n$(LST_N_MAP_LIST_SEP_WOP)\\n*_lint.txt\\n*.*\\n" >> $@; \
 $(ECHO) "FILTERNAME=Source Files\\nHeader Files\\nMakeSupport\\nError Files\\nList and Map Files\\nPCLint Files\\nOther Files\\n"   >> $@; \
 $(ECHO) "FILTERAPPCOMMAND=\\n\\n\\n\\n\\n\\n\\n"                                                                                    >> $@; \
 $(ECHO) "FILTERASSOCIATEFILETYPES=0 0 0 0 0 0 0 "                                                                                   >> $@; \
 $(ECHO) "[FILES]"                                                                                                                   >> $@; \
 for src in $(subst \,\\,$(SOURCES)); do                                                                                                    \
     $(ECHO) $$src                                                                                                                   >> $@; \
 done;                                                                                                                                      \
 for inc in $(subst \ ,???,$(subst \,\\,$(INCFILE_LIST))); do                                                                               \
     $(ECHO) $$inc | $(SED) 's/???/ /gp'                                                                                             >> $@; \
 done;                                                                                                                                      \
 for err in $(foreach SFX, $(ERR_SUFFIX_LIST),$(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%.$(SFX),$(BUILD_OBJECTS))); do                       \
     $(ECHO) $(ERR_PATH)\\$$err                                                                                                      >> $@; \
 done;                                                                                                                                      \
 $(ECHO) "$(ERR_PATH)\$(PROJECT_NAME).$(ERR_SUFFIX)"                                                                                 >> $@; \
 for lst in $(foreach SFX, $(LST_SUFFIX_LIST),$(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%.$(SFX),$(BUILD_OBJECTS))); do                       \
     $(ECHO) $(LST_PATH)\\$$lst                                                                                                      >> $@; \
 done;                                                                                                                                      \
 $(ECHO) ".\$(PROJECT_NAME).map"                                                                                                     >> $@; \
 for lint in $(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%_lint.txt,$(BUILD_OBJECTS)); do                                                       \
     $(ECHO) $(LOG_PATH)\\$$lint                                                                                                     >> $@; \
 done;                                                                                                                                      \
 for mke in $(MAKESUPPORT_LIST); do                                                                                                         \
     $(ECHO) .\\$$mke                                                                                                                >> $@; \
 done;                                                                                                                                      \
 $(ECHO) "[ASSOCIATION]"                                                                                                             >> $@; \
 $(ECHO) "...done";                                                                                                                         \
 $(ECHO) "";

#-----------------------------------------------------------------------------
# SlickeEdit 10 project file
#-----------------------------------------------------------------------------
slick10: $(PROJECT_NAME)10.vpj $(PROJECT_NAME)10.vpw

$(PROJECT_NAME)10.vpw: force
	@$(ECHO) "Generating SlickEdit 10 Workspace: $(PROJECT_NAME)10.vpw ..."; \
 $(ECHO) '<Workspace Version="10.0" VendorName="SlickEdit">'                 > $@; \
 $(ECHO) '	<Projects>'                                                     >> $@; \
 $(ECHO) '		<Project File="$(PROJECT_NAME)10.vpj"/>'                    >> $@; \
 $(ECHO) '	</Projects>'                                                    >> $@; \
 $(ECHO) '</Workspace>'                                                     >> $@; \
 $(ECHO) "...done";                                                         \
 $(ECHO) "";

$(PROJECT_NAME)10.vpj: force
	@$(ECHO) "Generating SlickEdit 10 Project File: $(PROJECT_NAME)10.vpj ...";                                                             \
 $(ECHO) '<Project'                                                                                                                   > $@; \
 $(ECHO) '    Version="10.0"'                                                                                                        >> $@; \
 $(ECHO) '    VendorName="SlickEdit"'                                                                                                >> $@; \
 $(ECHO) '    TemplateName="(Other)"'                                                                                                >> $@; \
 $(ECHO) '    WorkingDir=".">'                                                                                                       >> $@; \
 $(ECHO) '    <Config'                                                                                                               >> $@; \
 $(ECHO) '        Name="Release"'                                                                                                    >> $@; \
 $(ECHO) '        OutputFile=""'                                                                                                     >> $@; \
 $(ECHO) '        CompilerConfigName="">'                                                                                            >> $@; \
 $(ECHO) '        <Menu>'                                                                                                            >> $@; \
 $(ECHO) '            <Target'                                                                                                       >> $@; \
 $(ECHO) '                Name="Compile"'                                                                                            >> $@; \
 $(ECHO) '                MenuCaption="&amp;Compile"'                                                                                >> $@; \
 $(ECHO) '                CaptureOutputWith="ProcessBuffer"'                                                                         >> $@; \
 $(ECHO) '                SaveOption="SaveCurrent"'                                                                                  >> $@; \
 $(ECHO) '                RunFromDir="%rw"'                                                                                          >> $@; \
 $(ECHO) '                ClearProcessBuffer="1">'                                                                                   >> $@; \
 $(ECHO) '                <Exec CmdLine="set ERR_TO_STDOUT=1 && m.bat $(OBJ_PATH)\%n.$(OBJ_SUFFIX)"/>'                               >> $@; \
 $(ECHO) '            </Target>'                                                                                                     >> $@; \
 $(ECHO) '            <Target'                                                                                                       >> $@; \
 $(ECHO) '                Name="Build"'                                                                                              >> $@; \
 $(ECHO) '                MenuCaption="&amp;Build"'                                                                                  >> $@; \
 $(ECHO) '                CaptureOutputWith="ProcessBuffer"'                                                                         >> $@; \
 $(ECHO) '                SaveOption="SaveWorkspaceFiles"'                                                                           >> $@; \
 $(ECHO) '                RunFromDir="%rw"'                                                                                          >> $@; \
 $(ECHO) '                ClearProcessBuffer="1">'                                                                                   >> $@; \
 $(ECHO) '                <Exec CmdLine="set ERR_TO_STDOUT=1 && m.bat"/>'                                                            >> $@; \
 $(ECHO) '            </Target>'                                                                                                     >> $@; \
 $(ECHO) '            <Target'                                                                                                       >> $@; \
 $(ECHO) '                Name="Rebuild"'                                                                                            >> $@; \
 $(ECHO) '                MenuCaption="&amp;Rebuild"'                                                                                >> $@; \
 $(ECHO) '                CaptureOutputWith="ProcessBuffer"'                                                                         >> $@; \
 $(ECHO) '                SaveOption="SaveWorkspaceFiles"'                                                                           >> $@; \
 $(ECHO) '                RunFromDir="%rw"'                                                                                          >> $@; \
 $(ECHO) '                ClearProcessBuffer="1">'                                                                                   >> $@; \
 $(ECHO) '                <Exec CmdLine="set ERR_TO_STDOUT=1 && b.bat"/>'                                                            >> $@; \
 $(ECHO) '            </Target>'                                                                                                     >> $@; \
 $(ECHO) '            <Target'                                                                                                       >> $@; \
 $(ECHO) '                Name="Clean"'                                                                                              >> $@; \
 $(ECHO) '                MenuCaption="&amp;Clean"'                                                                                  >> $@; \
 $(ECHO) '                CaptureOutputWith="ProcessBuffer"'                                                                         >> $@; \
 $(ECHO) '                SaveOption="SaveWorkspaceFiles"'                                                                           >> $@; \
 $(ECHO) '                RunFromDir="%rw"'                                                                                          >> $@; \
 $(ECHO) '                ClearProcessBuffer="1">'                                                                                   >> $@; \
 $(ECHO) '                <Exec CmdLine="m.bat clean"/>'                                                                             >> $@; \
 $(ECHO) '            </Target>'                                                                                                     >> $@; \
 $(ECHO) '            <Target'                                                                                                       >> $@; \
 $(ECHO) '                Name="Depend"'                                                                                             >> $@; \
 $(ECHO) '                MenuCaption="&amp;Depend"'                                                                                 >> $@; \
 $(ECHO) '                CaptureOutputWith="ProcessBuffer"'                                                                         >> $@; \
 $(ECHO) '                SaveOption="SaveWorkspaceFiles"'                                                                           >> $@; \
 $(ECHO) '                RunFromDir="%rw"'                                                                                          >> $@; \
 $(ECHO) '                ClearProcessBuffer="1">'                                                                                   >> $@; \
 $(ECHO) '                <Exec CmdLine="m.bat depend"/>'                                                                            >> $@; \
 $(ECHO) '            </Target>'                                                                                                     >> $@; \
 $(ECHO) '            <Target'                                                                                                       >> $@; \
 $(ECHO) '                Name="Preprocess"'                                                                                         >> $@; \
 $(ECHO) '                MenuCaption="&amp;Preprocess"'                                                                             >> $@; \
 $(ECHO) '                CaptureOutputWith="ProcessBuffer"'                                                                         >> $@; \
 $(ECHO) '                SaveOption="SaveWorkspaceFiles"'                                                                           >> $@; \
 $(ECHO) '                RunFromDir="%rw"'                                                                                          >> $@; \
 $(ECHO) '                ClearProcessBuffer="1">'                                                                                   >> $@; \
 $(ECHO) '                <Exec CmdLine="m.bat  $(LOG_PATH)\%n.%e"/>'                                                                >> $@; \
 $(ECHO) '            </Target>'                                                                                                     >> $@; \
 $(ECHO) '            <Target'                                                                                                       >> $@; \
 $(ECHO) '                Name="PCLint"'                                                                                             >> $@; \
 $(ECHO) '                MenuCaption="&amp;PCLint"'                                                                                 >> $@; \
 $(ECHO) '                CaptureOutputWith="ProcessBuffer"'                                                                         >> $@; \
 $(ECHO) '                SaveOption="SaveWorkspaceFiles"'                                                                           >> $@; \
 $(ECHO) '                RunFromDir="%rw"'                                                                                          >> $@; \
 $(ECHO) '                ClearProcessBuffer="1">'                                                                                   >> $@; \
 $(ECHO) '                <Exec CmdLine="m.bat $(LOG_PATH)\%n_lint.txt"/>'                                                           >> $@; \
 $(ECHO) '            </Target>'                                                                                                     >> $@; \
 $(ECHO) '            <Target'                                                                                                       >> $@; \
 $(ECHO) '                Name="PCLintAll"'                                                                                          >> $@; \
 $(ECHO) '                MenuCaption="&amp;PCLintAll"'                                                                              >> $@; \
 $(ECHO) '                CaptureOutputWith="ProcessBuffer"'                                                                         >> $@; \
 $(ECHO) '                SaveOption="SaveWorkspaceFiles"'                                                                           >> $@; \
 $(ECHO) '                RunFromDir="%rw"'                                                                                          >> $@; \
 $(ECHO) '                ClearProcessBuffer="1">'                                                                                   >> $@; \
 $(ECHO) '                <Exec CmdLine="m.bat pclint"/>'                                                                            >> $@; \
 $(ECHO) '            </Target>'                                                                                                     >> $@; \
 $(ECHO) '            <Target'                                                                                                       >> $@; \
 $(ECHO) '                Name="version"'                                                                                            >> $@; \
 $(ECHO) '                MenuCaption="&amp;version"'                                                                                >> $@; \
 $(ECHO) '                CaptureOutputWith="ProcessBuffer"'                                                                         >> $@; \
 $(ECHO) '                SaveOption="SaveWorkspaceFiles"'                                                                           >> $@; \
 $(ECHO) '                RunFromDir="%rw"'                                                                                          >> $@; \
 $(ECHO) '                ClearProcessBuffer="1">'                                                                                   >> $@; \
 $(ECHO) '                <Exec CmdLine="m.bat version"/>'                                                                           >> $@; \
 $(ECHO) '            </Target>'                                                                                                     >> $@; \
 $(ECHO) '            <Target'                                                                                                       >> $@; \
 $(ECHO) '                Name="Doxygen"'                                                                                            >> $@; \
 $(ECHO) '                MenuCaption="&amp;Doxygen"'                                                                                >> $@; \
 $(ECHO) '                CaptureOutputWith="ProcessBuffer"'                                                                         >> $@; \
 $(ECHO) '                SaveOption="SaveWorkspaceFiles"'                                                                           >> $@; \
 $(ECHO) '                RunFromDir="%rw"'                                                                                          >> $@; \
 $(ECHO) '                ClearProcessBuffer="1">'                                                                                   >> $@; \
 $(ECHO) '                <Exec CmdLine="m.bat doxygen"/>'                                                                           >> $@; \
 $(ECHO) '            </Target>'                                                                                                     >> $@; \
 $(ECHO) '        </Menu>'                                                                                                           >> $@; \
 $(ECHO) '        <Includes>'                                                                                                        >> $@; \
 $(ECHOESC) $(foreach SRC,$(INC_LIST),                                                                                                   \
                '\n            <Include Dir="$(subst \,\\,$(subst /,\,$(SRC)))"/>'                                                          \
    )                                                                                                                                >> $@; \
 $(ECHO) '        </Includes>'                                                                                                       >> $@; \
 $(ECHO) '    </Config>'                                                                                                             >> $@; \
 $(ECHO) '    <Files>'                                                                                                               >> $@; \
 $(ECHO) '        <Folder'                                                                                                           >> $@; \
 $(ECHO) '            Name="Source Files"'                                                                                           >> $@; \
 $(ECHO) '            Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d;*.m;*.mm;*.go">' >> $@; \
 $(ECHOESC) $(foreach SRC,$(SOURCES),                                                                                                       \
                '\n            <F N="$(subst \,\\,$(subst /,\,$(SRC)))"/>'                                                                  \
    )                                                                                                                                >> $@; \
 $(ECHO) '        </Folder>'                                                                                                         >> $@; \
 $(ECHO) '        <Folder'                                                                                                           >> $@; \
 $(ECHO) '            Name="Header Files"'                                                                                           >> $@; \
 $(ECHO) '            Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">'                                                     >> $@; \
 $(ECHOESC) $(foreach SRC,$(INCFILE_LIST),                                                                                                  \
                '\n            <F N="$(subst \,\\,$(subst /,\,$(SRC)))"/>'                                                                  \
    )                                                                                                                                >> $@; \
 $(ECHO) '        </Folder>'                                                                                                         >> $@; \
 $(ECHO) '        <Folder'                                                                                                           >> $@; \
 $(ECHO) '            Name="MakeSupport"'                                                                                            >> $@; \
 $(ECHO) '            Filters="*.bat;*.make;*.config;*.defines;*.dep;*.lint">'                                                       >> $@; \
 $(ECHOESC) $(foreach SRC,$(MAKESUPPORT_LIST),                                                                                              \
                '\n            <F N="$(subst \,\\,$(subst /,\,$(SRC)))"/>'                                                                  \
    )                                                                                                                                >> $@; \
 $(ECHO) '        </Folder>'                                                                                                         >> $@; \
 $(ECHO) '        <Folder'                                                                                                           >> $@; \
 $(ECHO) '            Name="Error Files"'                                                                                            >> $@; \
 $(ECHO) '            Filters="*.err">'                                                                                              >> $@; \
 $(ECHOESC) $(foreach SRC, $(foreach SFX, $(ERR_SUFFIX_LIST),                                                                               \
                 $(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%.$(SFX),$(BUILD_OBJECTS))),                                                       \
                 '\n            <F N="$(ERR_PATH)\\$(SRC)" />'                                                                              \
   )                                                                                                                                 >> $@; \
 $(ECHO) '        </Folder>'                                                                                                         >> $@; \
 $(ECHO) '        <Folder'                                                                                                           >> $@; \
 $(ECHO) '            Name="List and Map Files"'                                                                                     >> $@; \
 $(ECHO) '            Filters="*.lst;*.ls;*.src;*.map">'                                                                             >> $@; \
 $(ECHOESC) $(foreach SRC, $(foreach SFX, $(LST_SUFFIX_LIST),                                                                               \
                 $(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%.$(SFX),$(BUILD_OBJECTS))),                                                       \
                 '\n            <F N="$(LST_PATH)\\$(SRC)" />'                                                                              \
   )                                                                                                                                 >> $@; \
 $(ECHO) '            <F N="$(PROJECT_NAME).map" />'                                                                                 >> $@; \
 $(ECHO) '        </Folder>'                                                                                                         >> $@; \
 $(ECHO) '        <Folder'                                                                                                           >> $@; \
 $(ECHO) '            Name="PCLint Files"'                                                                                           >> $@; \
 $(ECHO) '            Filters="*.txt;*.lnt">'                                                                                        >> $@; \
 $(ECHOESC) $(foreach SRC, $(foreach SFX, $(LST_SUFFIX_LIST),                                                                               \
                 $(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%_lint.txt,$(BUILD_OBJECTS))),                                                     \
                 '\n            <F N="$(LOG_PATH)\\$(SRC)" />'                                                                              \
   )                                                                                                                                 >> $@; \
 $(ECHO) '        </Folder>'                                                                                                         >> $@; \
 $(ECHO) '        <Folder'                                                                                                           >> $@; \
 $(ECHO) '            Name="Other Files"'                                                                                            >> $@; \
 $(ECHO) '            Filters=""/>'                                                                                                  >> $@; \
 $(ECHO) '    </Files>'                                                                                                              >> $@; \
 $(ECHO) '</Project>'                                                                                                                >> $@; \
 $(ECHO) "...done";                                                                                                                         \
 $(ECHO) "";

#-----------------------------------------------------------------------------
# create CodeWright project file
#-----------------------------------------------------------------------------
codewright: del_codewright_pjt $(PROJECT_NAME).psp $(PROJECT_NAME).pjt

del_codewright_pjt: force
	@$(ECHO) "Deleting old Codewright Project Files/Directories:";                                    \
 $(ECHO) "    $(PROJECT_NAME).pjt, $(PROJECT_NAME).sbl, $(PROJECT_NAME).psp $(PROJECT_NAME).CS_";         \
 if [ -f $(PROJECT_NAME).pjt ] && [ -w $(PROJECT_NAME).pjt ]; then                                        \
     $(RM) $(PROJECT_NAME).pjt;                                                                           \
 fi;                                                                                                      \
 if [ -f $(PROJECT_NAME).sbl ] && [ -w $(PROJECT_NAME).sbl ]; then                                        \
     $(RM) $(PROJECT_NAME).sbl;                                                                           \
 fi;                                                                                                      \
 if [ -f $(PROJECT_NAME).psp ] && [ -w $(PROJECT_NAME).psp ]; then                                        \
     $(RM) $(PROJECT_NAME).psp;                                                                           \
 fi;                                                                                                      \
 if [ -d $(PROJECT_NAME).CS_ ] && [ -w $(PROJECT_NAME).CS_ ]; then                                        \
     $(RRM) $(PROJECT_NAME).CS_;                                                                          \
 fi;                                                                                                      \
 $(ECHO) "...done";                                                                                       \
 $(ECHO) "";

$(PROJECT_NAME).psp: force
	@$(ECHO) "Generating Codewright Project Space File: $(PROJECT_NAME).psp ...";                     \
 $(ECHO) ";Codewright Project Space File (do not remove or modify this line)"                       > $@; \
 $(ECHO) ""                                                                                        >> $@; \
 $(ECHO) "[State]"                                                                                 >> $@; \
 $(ECHO) ""                                                                                        >> $@; \
 $(ECHO) "[Project.\".\\$(PROJECT_NAME).pjt\"]"                                                    >> $@; \
 $(ECHO) "...done";                                                                                       \
 $(ECHO) "";

$(PROJECT_NAME).pjt: $(PROJECT_NAME).psp
	@$(ECHO) "Generating Codewright Project File: $(PROJECT_NAME).pjt ...";                           \
 $(ECHO) ";Codewright Project File (do not remove or modify this line)"                             > $@; \
 $(ECHO) ""                                                                                        >> $@; \
 $(ECHO) "[VersionControl:SourceSafe]"                                                             >> $@; \
 $(ECHO) ""                                                                                        >> $@; \
 $(ECHO) "[VersionControl:VCS]"                                                                    >> $@; \
 $(ECHO) ""                                                                                        >> $@; \
 $(ECHO) "[Tools]"                                                                                 >> $@; \
 $(ECHO) "ToolDeleteList"                                                                          >> $@; \
 $(ECHO) "ToolAddCmd='\$$_custom_tool_\$$_1','Organi',1342177584,"                                        \
             "'R:\CAN\Organi\Exec\conorg.exe'"                                                     >> $@; \
 $(ECHO) "ToolAddCmd='\$$_custom_tool_\$$_2','CANgen',1342177280,"                                        \
             "'D:\uti\cangen\exec\cangen'"                                                         >> $@; \
 $(ECHO) "ToolAddCmd='\$$_custom_tool_\$$_3','Lint with current file',1342177712,"                        \
             "'set CW_ACTIVE=1 && m.bat log\%f_lint.txt'"                                          >> $@; \
 $(ECHO) ""                                                                                        >> $@; \
 $(ECHO) "[Compiler]"                                                                              >> $@; \
 $(ECHOESC) "CompilerAddCmdEx='\$$_cw_proj_hash_\$$','',1073741824,'',0,"                                 \
            "'set ERR_TO_STDOUT=1 && m.bat',432,'set ERR_TO_STDOUT=1 && m.bat',432,"                      \
            "'set ERR_TO_STDOUT=1 && m.bat rebuild',432,'set ERR_TO_STDOUT=1 && m.bat rebuild',432,"      \
            "'',0,'',0,"                                                                                  \
            "'_ErrorInfoDefault','_PCLint1ErrorInfo','_PCLint2ErrorInfo',"                                \
            "'proj.err','%x'"                                                                      >> $@; \
 $(ECHO) ""                                                                                        >> $@; \
 $(ECHO) "[State]"                                                                                 >> $@; \
 $(ECHO) "SysSetCwd='$(subst /,\\,$(CURDIR))'"                                                     >> $@; \
 $(ECHO) ""                                                                                        >> $@; \
 $(ECHO) "[Editor]"                                                                                >> $@; \
 $(ECHO) "FilterProjDeleteList"                                                                    >> $@; \
 $(ECHO) "FilterProjAdd='Source','source\*.c;source\*.cpp;source\*.h;source\*.C;source\*.H;source\*.$(ASM_SUFFIX)',-1" >> $@; \
 $(ECHO) "FilterProjAdd='Include','include\*.c;include\*.cpp;include\*.h;include\*.C;include\*.H;include\*.$(ASM_SUFFIX)',-1" >> $@; \
 $(ECHO) "FilterProjAdd='GenData','$(GENDATA_DIR)\*.c;$(GENDATA_DIR)\*.cpp;$(GENDATA_DIR)\*.h;$(GENDATA_DIR)\*.C;$(GENDATA_DIR)\*.H;$(GENDATA_DIR)\*.$(ASM_SUFFIX)',-1" >> $@; \
 $(ECHOESC) $(foreach MODULE,$(MODULE_USED_LST),                                     \
                "\nFilterProjAdd='$(call compName,$(MODULE))',"                                           \
                $(foreach DIR,$(subst \,\\,$(dir $(call compSources,$(MODULE)))),                         \
                    "'$(DIR)*.c;$(DIR)*.cpp;$(DIR)*.h;$(DIR)*.C;$(DIR)*.H;$(DIR)\*.$(ASM_SUFFIX)'"        \
                )                                                                                         \
                ",-1"                                                                                     \
            )                                                                                      >> $@; \
 $(ECHO) "FilterProjAdd='External Dependencies','*.c;*.cpp*.h;*.C;*.H;*.$(ASM_SUFFIX)',-1"         >> $@; \
 $(ECHO) "FilterProjAdd='MakeSupport','$(MAKESUPPORT_LIST_SEP)',-1"                                >> $@; \
 $(ECHO) "FilterProjAdd='Error Files','$(ERR_LIST_SEP)',-1"                                        >> $@; \
 $(ECHO) "FilterProjAdd='List and Map Files','$(LST_N_MAP_LIST_SEP)',-1"                           >> $@; \
 $(ECHO) "FilterProjAdd='PCLint Files','*_lint.txt',-1"                                            >> $@; \
 $(ECHO) ""                                                                                        >> $@; \
 $(ECHOESC) '[Files]' $(CW_FILES)                                                                  >> $@; \
 $(ECHO) "...done";                                                                                       \
 $(ECHO) "";

define CW_FILES
    $(foreach SRC,$(SOURCES),'\n$(subst \,\\,$(SRC))')                           \
    $(foreach SRC,$(ASM_SOURCES),'\n$(subst \,\\,$(SRC))')                       \
    $(subst ???, ,$(foreach INC,$(subst \,\\,$(subst \ ,???,$(INCFILE_LIST))),   \
        '\n$(subst /,\\,$(INC))'                                                 \
    ))                                                                           \
    $(foreach SRC, $(foreach SFX, $(ERR_SUFFIX_LIST),                            \
        $(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%.$(SFX),$(BUILD_OBJECTS))),     \
        '\n$(ERR_PATH)\\$(SRC)'                                                  \
    )                                                                            \
    '\n$(subst \,\\,$(ERR_PATH)\$(PROJECT_NAME).$(ERR_SUFFIX))'                  \
    $(foreach SRC, $(foreach SFX, $(LST_SUFFIX_LIST),                            \
        $(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%.$(SFX),$(BUILD_OBJECTS))),     \
        '\n$(LST_PATH)\\$(SRC)'                                                  \
    )                                                                            \
    '\n.\\$(PROJECT_NAME).map'                                                   \
    $(foreach SRC,                                                               \
        $(patsubst $(OBJ_PATH)\\%.$(OBJ_SUFFIX),%_lint.txt,$(BUILD_OBJECTS)),    \
        '\n$(LOG_PATH)\\$(SRC)'                                                  \
    )                                                                            \
    $(foreach SRC,$(MAKESUPPORT_LIST),                                           \
        '\n.\\$(SRC)'                                                            \
    )
endef

#-----------------------------------------------------------------------------
# Preparation for QAC Misra
#-----------------------------------------------------------------------------
MISRA_REPORTS       = $(foreach MODULE,$(MODULE_USED_LST),misra\$(MODULE)_report.txt)
MISRA_MERGE_REPORTS = $(foreach MODULE,$(MODULE_USED_LST),misra\$(MODULE)_merge_reports)
MISRA_PROJECTS      = $(foreach MODULE,$(MODULE_USED_LST),misra\$(MODULE)_misra.prj)

qac_common_prerequisites: $(PROJECT_NAME).p_a         \
                          $(PROJECT_NAME).p_c         \
                          all_MISRA_rules_QAC70.p_s   \
                          qacinfo                     \
                          misra                       \
                          misra/tmp

#-----------------------------------------------------------------------------
# create QAC Misra checker config files
#-----------------------------------------------------------------------------
qac: $(PROJECT_NAME)_misra.prj   \
     all_MISRA_rules_QAC70.p_s   \
     qac_common_prerequisites

qacinfo: force
	@$(ECHO) "You have to copy your compiler includes to $(QAC_CC_INCLUDE) in order to run QAC successfully!"; \
 $(ECHO) "";

misra:
	@$(MKDIR) misra

misra/tmp:
	@$(MKDIR) misra/tmp

ifeq ($(QAC_CC_INCLUDE),)
  QAC_CC_INCLUDE = $(ROOT)\system
endif

ifeq ($(QAC_INCLUDES),)
    QAC_INCLUDES=       $(COMMON_INC)         \
                        $(FBLCAN_INC)         \
                        include               \
                        $(GENDATA_DIR)        \
                        $(SUBDIRS)
endif

QAC_INCLUDE_LIST = $(subst \,/,$(subst \ ,???, \
                    $(QAC_INCLUDES)           \
                    $(ADDITIONAL_INCLUDES)    \
                    $(QAC_CC_INCLUDE)))

ifneq ($(SUPPRESS_COMP_MAKE_INCLUDES),1)
QAC_INCLUDE_LIST += $(subst \,/,$(subst \ ,???,$(COMP_MAKE_INC)))
endif


QAC_INCLUDES_1 = $(subst ???,\ ,$(addprefix -I, $(sort $(call toLower,QAC_INCLUDE_LIST))))
QAC_INCLUDES_2 = $(subst \ ,???,$(subst /,\\,$(subst -I,,$(QAC_INCLUDES_1))))
QAC_INCLUDES_3   = $(subst ???, ,$(foreach FILE,$(QAC_INCLUDES_2),\n-i $(if $(findstring :\\,$(FILE)),$(FILE),"$(QAC_CURDIR)\\$(FILE)")))

QAC_SYSTEM_1 = $(subst \,/,$(subst \ ,???,$(ROOT)\system))
QAC_SYSTEM_2 = $(subst ???,\ ,$(addprefix -I, $(sort $(call toLower,QAC_SYSTEM_1))))
QAC_SYSTEM_3 = $(subst \ ,???,$(subst /,\\,$(subst -I,,$(QAC_SYSTEM_2))))
QAC_SYSTEM   = $(subst ???, ,$(foreach FILE,$(QAC_SYSTEM_3),\n-I "$(QAC_CURDIR)\\$(FILE)"))

# Suppress these files in Qac report

QAC_SUPPRESS  = $(subst \,/,$(subst \ ,???, \
                        $(QAC_SUPPRESS_OUT_DIR) \
                        $(QAC_SUPPRESS_OUT_FILE)))
                                               
QAC_SUPPRESS_1 = $(subst ???,\ ,$(addprefix -Q, $(sort $(call toLower,QAC_SUPPRESS))))
QAC_SUPPRESS_2 = $(subst \ ,???,$(subst /,\\,$(subst -Q,,$(QAC_SUPPRESS_1))))
QAC_SUPPRESS_3   = $(subst ???, ,$(foreach FILE,$(QAC_SUPPRESS_2),\n-Q $(if $(findstring :\\,$(FILE)),$(FILE),"$(QAC_CURDIR)\\$(FILE)")))

QAC_CURDIR = $(subst \,\\,$(CURDIR))

ifeq ($(QAC_PERSONALITY),)
    QAC_WARNING = "Warning: QAC Compiler personality generation is not implemented for this platform. Settings must be adjusted manually!\n\n"
endif

ifeq ($(QAC_SUPPRESS_HEADERS),)
    QAC_HEADER_SETTING  = "-HDR-"
else
    QAC_HEADER_INCLUDES = $(subst -i,-q,$(QAC_INCLUDES_3))
    QAC_HEADER_SETTING  = "-HDR+"
endif

ifeq ($(MESSAGE_PERSONALITY_FILE_LOCATION),)
MESSAGE_PERSONALITY_FILE_LOCATION  = \\\\vi.vector.int\\Backup\\PES\\DevelopmentTools\\others\\PRQA\\automation\\report\\all_MISRA_rules_QAC70.p_s
endif
ifeq ($(QACTOOL_PATH),)
QACTOOL_PATH = \\\\vi.vector.int\\Backup\\PES\\DevelopmentTools\\others\\PRQA\\automation\\report\\QAC7.0
endif

$(PROJECT_NAME).p_a: Makefile Makefile.project.part.defines Makefile.config $(PROJECT_NAME).dep
	@$(ECHO) "Generating QAC7 project file: $@ ...";                      \
 $(ECHO) "-il 0"                                                 > $@; \
 $(ECHOESC) '$(QAC_INCLUDES_3)'                                 >> $@; \
 $(ECHOESC) '$(QAC_HEADER_INCLUDES)'                            >> $@; \
 $(ECHOESC) '$(QAC_SUPPRESS_3)'                                 >> $@; \
 $(ECHO) "-sty exdented"                                        >> $@; \
 $(ECHO) "-tab 2"                                               >> $@; \
 $(ECHO) "-wc abort=5126"                                       >> $@; \
 $(ECHO) "-wc asctime=5127"                                     >> $@; \
 $(ECHO) "-wc atof=5125"                                        >> $@; \
 $(ECHO) "-wc atoi=5125"                                        >> $@; \
 $(ECHO) "-wc atol=5125"                                        >> $@; \
 $(ECHO) "-wc calloc=5118"                                      >> $@; \
 $(ECHO) "-wc clock=5127"                                       >> $@; \
 $(ECHO) "-wc ctime=5127"                                       >> $@; \
 $(ECHO) "-wc difftime=5127"                                    >> $@; \
 $(ECHO) "-wc exit=5126"                                        >> $@; \
 $(ECHO) "-wc free=5118"                                        >> $@; \
 $(ECHO) "-wc getenv=5126"                                      >> $@; \
 $(ECHO) "-wc gmtime=5127"                                      >> $@; \
 $(ECHO) "-wc localtime=5127"                                   >> $@; \
 $(ECHO) "-wc longjmp=5122"                                     >> $@; \
 $(ECHO) "-wc malloc=5118"                                      >> $@; \
 $(ECHO) "-wc mktime=5127"                                      >> $@; \
 $(ECHO) "-wc raise=5123"                                       >> $@; \
 $(ECHO) "-wc realloc=5118"                                     >> $@; \
 $(ECHO) "-wc signal=5123"                                      >> $@; \
 $(ECHO) "-wc strftime=5127"                                    >> $@; \
 $(ECHO) "-wc system=5126"                                      >> $@; \
 $(ECHO) "-wc time=5127"                                        >> $@; \
 $(ECHO) "-en ASC"                                              >> $@; \
 $(ECHO) "-maxerr 0"                                            >> $@; \
 $(ECHO) "-ppl+"                                                >> $@; \
 $(ECHO) "-ppf+"                                                >> $@; \
 $(ECHO) "-met+"                                                >> $@; \
 $(ECHO) "-ppm-"                                                >> $@; \
 $(ECHO) "-co a"                                                >> $@; \
 $(ECHO) "-k+r gs"                                              >> $@; \
 $(ECHO) "-thresh \"STPTH>80:6010\""                            >> $@; \
 $(ECHO) "-thresh \"STCYC>10:6030\""                            >> $@; \
 $(ECHO) "-thresh \"STCAL>7:6050\""                             >> $@; \
 $(ECHO) "-thresh \"STPAR>5:6060\""                             >> $@; \
 $(ECHO) "-thresh \"STMIF>4:6080\""                             >> $@; \
 $(ECHO) "-thresh \"STBAK>0:6150\""                             >> $@; \
 $(ECHO) "-ss+"                                                 >> $@; \
 $(ECHO) "-sr-"                                                 >> $@; \
 $(ECHO) "-mll 0"                                               >> $@; \
 $(ECHO) "...done";                                                    \
 $(ECHO) "";

$(PROJECT_NAME).p_c: Makefile Makefile.config
	@$(ECHO) "Generating QAC7 compiler configuration file: $@ ..."; \
 $(ECHOESC) '$(QAC_SYSTEM)'                                      > $@; \
 $(ECHOESC) '$(subst -I,-Q,$(QAC_SYSTEM))'                      >> $@; \
 $(QAC_PERSONALITY)                                                    \
 $(ECHO) "...done";                                                    \
 $(ECHO) "";                                                           \
 $(ECHOESC) $(QAC_WARNING);

QC=$(QAC_CURDIR)
QCP=$(QAC_CURDIR)\\$(PROJECT_NAME)
export QC
export QCP

$(PROJECT_NAME)_misra.prj: Makefile Makefile.project.part.defines Makefile.config $(PROJECT_NAME).dep
	@$(ECHO) "Generating QAC7 linker configuration file: $@ ..."; \
 $(ECHOESC) 'VersionTag45\n' \
            'StartProjectMarker\n' \
            'FolderName=$(PROJECT_NAME)\n' \
            'SourcePath='"$$QC"'\n'                                                  \
            'OutputPath='"$$QC"'\\misra\\tmp\n'                                      \
            'SubsPers='"$$QC"'\\all_MISRA_rules_QAC70.p_s\n' \
            'AnalPers='"$$QCP"'.p_a\n' \
            'CompPers='"$$QCP"'.p_c\n' \
            'EndContainedFilesMarker\n' \
            'StartSubProjectMarker\n' \
            'StartProjectMarker\n' \
            'FolderName=Source\n' \
            'SourcePath='"$$QC"'\n'                                                  \
            'OutputPath='"$$QC"'\\misra\\tmp\n'                                      \
            'SubsPers='"$$QC"'\\all_MISRA_rules_QAC70.p_s\n' \
            'AnalPers='"$$QCP"'.p_a\n' \
            'CompPers='"$$QCP"'.p_c\n'                               > $@
	@$(foreach FILE,$(APP_SOURCE_LST), \
	$(ECHOESC) "$$QC"'\\$(subst \,\\,$(FILE))\n' >>$@; )
	@$(ECHOESC) 'EndContainedFilesMarker\n' \
            'StartProjectMarker\n' \
            'FolderName=GenData\n' \
            'SourcePath='"$$QC"'\\\n' \
            'OutputPath='"$$QC"'\\misra\\tmp\n'                                      \
            'SubsPers='"$$QC"'\\all_MISRA_rules_QAC70.p_s\n' \
            'AnalPers='"$$QCP"'.p_a\n' \
            'CompPers='"$$QCP"'.p_c\n' >>$@
	@$(foreach FILE,$(subst \,\\,$(sort $(DATA_SOURCE_LST) $(MODULE_DATA_LST) $(MODULE_COMMON_LST))), \
	$(ECHOESC) "$$QC"'\\$(FILE)\n' >>$@ ; ) \
$(foreach GROUP,$(MODULE_USED_LST), \
                $(foreach DATA,$($(GROUP)_DATA), \
$(ECHOESC) "$$QC"'\\$(subst \,\\,$(DATA))\n' >>$@ ; \
                 ) \
) >>$@ 
	@$(ECHOESC) 'EndContainedFilesMarker\n' \
            $(foreach GROUP,$(MODULE_USED_LST), \
                'StartProjectMarker\n'                             \
                'FolderName=$(GROUP)\n'                            \
                'SourcePath='"$$QC"'\n'                            \
                'OutputPath='"$$QC"'\\misra\\tmp\\\n'              \
                'SubsPers='"$$QC"'\\all_MISRA_rules_QAC70.p_s\n'   \
                'AnalPers='"$$QCP"'.p_a\n'                         \
                'CompPers='"$$QCP"'.p_c\n'                         \
                $(foreach FILE,$(subst \,\\,$(call compSources,$(GROUP))), \
                    "$$QC"'\\$(ROOT)\\$(FILE)\n' \
                ) \
                'EndContainedFilesMarker\n' \
            ) \
            'EndSubProjectMarker\n' >> $@;
	@$(MV) $@ "$@.tmp" && $(SED) -n 's/^[ ]*//p' < "$@.tmp" > $@ && $(RM) "$@.tmp"
	@$(ECHO) "...done";
	@$(ECHO) ""

$(subst /,\,$(MISRA_PROJECTS)) : misra\\%_misra.prj: misra/%_misra.prj

.PRECIOUS: misra/%_misra.prj

misra/%_misra.prj: Makefile Makefile.project.part.defines Makefile.config $(PROJECT_NAME).dep
	@$(ECHO) "Generating QAC7 configuration file: $@ ..."; \
 $(ECHOESC) 'VersionTag45\n' \
            'StartProjectMarker\n' \
            'FolderName=$*\n' \
            'SourcePath='"$$QC"'\\\n' \
            'OutputPath='"$$QC"'\\misra\\tmp\\\n' \
            'SubsPers='"$$QC"'\\all_MISRA_rules_QAC70.p_s\n' \
            'AnalPers='"$$QCP"'.p_a\n' \
            'CompPers='"$$QCP"'.p_c\n' \
            $(foreach FILE,$(subst \,\\,$(call compSources,$(call _toUpper,$*))), \
                "$$QC\\$(ROOT)\\$(FILE)\n" \
            ) \
            $(foreach FILE,$(subst \,\\,$($(call _toUpper,$*_DATA))), \
                "$$QC\\$(FILE)\n" \
            ) \
            'EndContainedFilesMarker\n' | $(SED) -n 's/^[ ]*\(.*\)/\1/p'            > $@; \
 $(ECHO) "...done"; \
 $(ECHO) ""

all_MISRA_rules_QAC70.p_s: Makefile Makefile.project.part.defines Makefile.config $(PROJECT_NAME).dep
	@$(ECHO) "Generating QAC deviation list file: $@ ..."; \
 $(ECHO) "-rem \"EnablePostAnalysis=1\""                          > $@; \
 $(ECHO) "-rem \"ShellExe=$(QAC_PATH)\m2cm\bin\qacsa_m2cm.exe\"" >> $@; \
 $(ECHO) "-rem \"ShellParams=%Q %F -forget cmaf\""               >> $@; \
 $(ECHO) "-UP \"$(QAC_PATH)\m2cm\messages\\\""                   >> $@; \
 $(ECHO) "-USR .m2cm"                                            >> $@; \
 $(ECHO) "-SUMM-"                                                >> $@; \
 $(ECHO) "$(QAC_HEADER_SETTING)"                                 >> $@; \
 $(ECHO) "-REF+"                                                 >> $@; \
 $(ECHO) "-ONE-"                                                 >> $@; \
 $(ECHO) "-TEXT-"                                                >> $@; \
 $(CAT) $(MESSAGE_PERSONALITY_FILE_LOCATION)                     >> $@; \
 $(ECHO) "...done"; \
 $(ECHO) "";

#---------------------------------------------------------------------
 # run_qac sets the Environment necessary for qac and starts it over the commandline.
#---------------------------------------------------------------------
$(subst /,\,$(MISRA_REPORTS)) : misra\\%_report.txt: misra/%_report.txt

misra/%_report.txt: qac_common_prerequisites misra/%_misra.prj
	@export LM_LICENSE_FILE=$(QAC_LICENSE_SRV);                                          \
 export QACPATH=$(subst \,\\,"$(QAC_PATH)")\\;                                               \
 export QACBIN=$(subst \,\\,"$(QAC_PATH))"\\bin\\;                                           \
 export QACOUTPATH=$(subst \,\\,$(CURDIR))\\misra\\tmp\\;                                    \
 export QACHELPFILES=$(subst \,\\,"$(QAC_PATH)")\\help\\;                                    \
 export QACTEMP=$(subst \,\\,$(CURDIR))\\misra\\tmp\\;                                       \
 export PATH='/cygdrive/$(subst / ,\ ,$(subst :,,$(subst \,/,$(QAC_PATH))/bin)):/cygdrive/$(subst / ,\ ,$(subst :,,$(subst \,/,$(QAC_PATH))/m2cm/bin)):/cygdrive/c\WINDOWS\system32:$$PATH';\
 $(ECHO) "... performing MISRA analysis on component $*";                                    \
 qaw qac misra\\$*_misra.prj -maseq "pal %Q %P+ %L+" -etxt -fdisp qacoutput.txt;                   \
 $(ECHO) "... extracting qac version";                                                       \
 prjdsp QAC -ver $(VIA)  2>/dev/null 1>tmp1.txt;                                             \
 $(ECHO) "... running prjdsp";                                                               \
 prjdsp QAC $(VIA) $(call misraReportFiles,$*) > tmp2.txt;                  \
 $(ECHO) "... converting results (execute qactool)";                                         \
 $(ECHOESC) $(foreach FILE,$(addprefix .\\misra\\tmp\\,$(notdir $(call compSources,$(call _toUpper,$*)))),         \
                '$(FILE)\n'                                       \
            )  > inputfile.txt; \
 $(QACTOOL_PATH)/QACTool2.exe -c2 inputfile.txt;                                             \
 $(ECHO) "... merging reports";                                                              \
 $(CAT) tmp1.txt tmp2.txt QACtool.metric.txt > misra/$*_report.txt;                          \
 $(RM) inputfile.txt tmp1.txt tmp2.txt;

misraReportFiles = $(subst \,\\,$(call compSources,$(call _toUpper,$1))) \
                    \\misra\\tmp\\$1 \
                    $(addprefix \\misra\\tmp\\,$(notdir $($1_DATA)))

$(subst /,\,$(MISRA_MERGE_REPORTS)) : misra\\%_merge_reports: misra/%_merge_reports

misra/%_merge_reports:
	@if [ -z "$(MISRA_REPORT_DIR_LST)" ] ; then                                                                       \
     $(ECHO) "MISRA_REPORT_DIR_LST is not set. Please add all directories (containing the report file $*_report.txt) to the variable which should be used for the merged report"; \
     exit 1;                                                                                                              \
 else                                                                                                                     \
     $(ECHO) "Merging all reports from <$(MISRA_REPORT_DIR_LST)> to QACtool.MergedReports.txt";                           \
     $(ECHOESC) $(foreach DIR,$(MISRA_REPORT_DIR_LST),                                                                    \
                    '$(subst \,\\,$(DIR))\\$*_report.txt\n'                                                               \
                )                                                                                       >> inputfile.txt; \
     $(QACTOOL_PATH)/qactool2 -m inputfile.txt;                                                                           \
     $(RM) inputfile.txt;                                                                                                 \
     $(ECHO) "...done";                                                                                                   \
 fi

VIA = -via all_MISRA_rules_QAC70.p_s \
      -via $(PROJECT_NAME).p_a \
      -via $(PROJECT_NAME).p_c \
      -op misra\\tmp

##############################################################################
# Doc
##############################################################################
DOXYGEN = $(CMD_PATH)/doxygen/doxygen

DOXYGEN_EXCL_DIRS  += $(COMPILER_BASE) $(COMPILER_INC) $(COMPILER_BIN) $(COMPILER_LIB)
DOXYGEN_EXCL_DIRS_  = $(subst \ ,???,$(DOXYGEN_EXCL_DIRS))
DOXYGEN_EXCL_FILES_ = $(subst \ ,???,$(DOXYGEN_EXCL_FILES))

DOXYGEN_INPUT   = $(foreach FILE, \
                      $(sort $(filter-out \
                          $(subst \,/,$(call _toLower,$(DOXYGEN_EXCL_FILES_)                       \
                                          $(addsuffix /%.c,$(DOXYGEN_EXCL_DIRS_))                  \
                                          $(addsuffix /%.$(ASM_SUFFIX),$(DOXYGEN_EXCL_DIRS_))      \
                                          $(addsuffix /%.h,$(DOXYGEN_EXCL_DIRS_)))),               \
                          $(subst \,/,$(call _toLower,$(subst \ ,???,$(SOURCES) $(INCFILE_LIST)))) \
                      )),                                                                          \
                      \"$(subst ???, ,$(FILE))\"                                                   \
                  )
DOXYGEN_INCLUDE = $(foreach DIR, \
                      $(filter-out \
                          $(call _toLower,$(subst \\,/,$(subst \ ,???,$(DOXYGEN_EXCL_DIRS)))), \
                          $(subst \\,/,$(subst \ ,???,$(VERSION_DIR)))), \
                      \"$(subst ???, ,$(DIR)\") \
                  )

doxygen: $(PROJECT_NAME).doc.cfg
	@if [ -f $(DOXYGEN) ] ; then            \
     $(RM) -rf docs;                            \
     $(MKDIR) docs;                             \
     $(DOXYGEN) $(PROJECT_NAME).doc.cfg;        \
 else                                           \
     $(ECHO) "Doxygen not installed properly";  \
 fi;

$(PROJECT_NAME).doc.cfg: $(PROJECT_NAME).dep
	@$(ECHO) "Generating $@ ...";                                                          \
 $(ECHO) "# Doxyfile 1.5.5"                                                              > $@; \
 $(ECHO) ""                                                                             >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# Project related configuration options"                                      >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "DOXYFILE_ENCODING      = UTF-8"                                               >> $@; \
 $(ECHO) "PROJECT_NAME           = $(PROJECT_NAME)"                                     >> $@; \
 $(ECHO) "PROJECT_NUMBER         = "                                                    >> $@; \
 $(ECHO) "OUTPUT_DIRECTORY       = ."                                                   >> $@; \
 $(ECHO) "CREATE_SUBDIRS         = NO"                                                  >> $@; \
 $(ECHO) "OUTPUT_LANGUAGE        = English"                                             >> $@; \
 $(ECHO) "BRIEF_MEMBER_DESC      = YES"                                                 >> $@; \
 $(ECHO) "REPEAT_BRIEF           = YES"                                                 >> $@; \
 $(ECHO) "ABBREVIATE_BRIEF       = \"The \$$name class\" \\"                            >> $@; \
 $(ECHO) "                         \"The \$$name widget\" \\"                           >> $@; \
 $(ECHO) "                         \"The \$$name file\" \\"                             >> $@; \
 $(ECHO) "                         is \\"                                               >> $@; \
 $(ECHO) "                         provides \\"                                         >> $@; \
 $(ECHO) "                         specifies \\"                                        >> $@; \
 $(ECHO) "                         contains \\"                                         >> $@; \
 $(ECHO) "                         represents \\"                                       >> $@; \
 $(ECHO) "                         a \\"                                                >> $@; \
 $(ECHO) "                         an \\"                                               >> $@; \
 $(ECHO) "                         the"                                                 >> $@; \
 $(ECHO) "ALWAYS_DETAILED_SEC    = NO"                                                  >> $@; \
 $(ECHO) "INLINE_INHERITED_MEMB  = NO"                                                  >> $@; \
 $(ECHO) "FULL_PATH_NAMES        = NO"                                                  >> $@; \
 $(ECHO) "STRIP_FROM_PATH        = "                                                    >> $@; \
 $(ECHO) "STRIP_FROM_INC_PATH    = "                                                    >> $@; \
 $(ECHO) "SHORT_NAMES            = NO"                                                  >> $@; \
 $(ECHO) "JAVADOC_AUTOBRIEF      = NO"                                                  >> $@; \
 $(ECHO) "QT_AUTOBRIEF           = NO"                                                  >> $@; \
 $(ECHO) "MULTILINE_CPP_IS_BRIEF = NO"                                                  >> $@; \
 $(ECHO) "DETAILS_AT_TOP         = NO"                                                  >> $@; \
 $(ECHO) "INHERIT_DOCS           = YES"                                                 >> $@; \
 $(ECHO) "SEPARATE_MEMBER_PAGES  = NO"                                                  >> $@; \
 $(ECHO) "TAB_SIZE               = 2"                                                   >> $@; \
 $(ECHO) "ALIASES                = \"param_i=\\par Parameter Indexed:\\n\" \\"          >> $@; \
 $(ECHO) "                         \"context=\\par Call Context:\\n\""                  >> $@; \
 $(ECHO) "OPTIMIZE_OUTPUT_FOR_C  = YES"                                                 >> $@; \
 $(ECHO) "OPTIMIZE_OUTPUT_JAVA   = NO"                                                  >> $@; \
 $(ECHO) "OPTIMIZE_FOR_FORTRAN   = NO"                                                  >> $@; \
 $(ECHO) "OPTIMIZE_OUTPUT_VHDL   = NO"                                                  >> $@; \
 $(ECHO) "BUILTIN_STL_SUPPORT    = NO"                                                  >> $@; \
 $(ECHO) "CPP_CLI_SUPPORT        = NO"                                                  >> $@; \
 $(ECHO) "SIP_SUPPORT            = NO"                                                  >> $@; \
 $(ECHO) "DISTRIBUTE_GROUP_DOC   = YES"                                                 >> $@; \
 $(ECHO) "SUBGROUPING            = YES"                                                 >> $@; \
 $(ECHO) "TYPEDEF_HIDES_STRUCT   = NO"                                                  >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# Build related configuration options"                                        >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "EXTRACT_ALL            = YES"                                                 >> $@; \
 $(ECHO) "EXTRACT_PRIVATE        = YES"                                                 >> $@; \
 $(ECHO) "EXTRACT_STATIC         = YES"                                                 >> $@; \
 $(ECHO) "EXTRACT_LOCAL_CLASSES  = YES"                                                 >> $@; \
 $(ECHO) "EXTRACT_LOCAL_METHODS  = YES"                                                 >> $@; \
 $(ECHO) "EXTRACT_ANON_NSPACES   = YES"                                                 >> $@; \
 $(ECHO) "HIDE_UNDOC_MEMBERS     = NO"                                                  >> $@; \
 $(ECHO) "HIDE_UNDOC_CLASSES     = NO"                                                  >> $@; \
 $(ECHO) "HIDE_FRIEND_COMPOUNDS  = NO"                                                  >> $@; \
 $(ECHO) "HIDE_IN_BODY_DOCS      = NO"                                                  >> $@; \
 $(ECHO) "INTERNAL_DOCS          = NO"                                                  >> $@; \
 $(ECHO) "CASE_SENSE_NAMES       = NO"                                                  >> $@; \
 $(ECHO) "HIDE_SCOPE_NAMES       = NO"                                                  >> $@; \
 $(ECHO) "SHOW_INCLUDE_FILES     = YES"                                                 >> $@; \
 $(ECHO) "INLINE_INFO            = YES"                                                 >> $@; \
 $(ECHO) "SORT_MEMBER_DOCS       = NO"                                                  >> $@; \
 $(ECHO) "SORT_BRIEF_DOCS        = NO"                                                  >> $@; \
 $(ECHO) "SORT_GROUP_NAMES       = NO"                                                  >> $@; \
 $(ECHO) "SORT_BY_SCOPE_NAME     = NO"                                                  >> $@; \
 $(ECHO) "GENERATE_TODOLIST      = YES"                                                 >> $@; \
 $(ECHO) "GENERATE_TESTLIST      = YES"                                                 >> $@; \
 $(ECHO) "GENERATE_BUGLIST       = YES"                                                 >> $@; \
 $(ECHO) "GENERATE_DEPRECATEDLIST= YES"                                                 >> $@; \
 $(ECHO) "ENABLED_SECTIONS       = "                                                    >> $@; \
 $(ECHO) "MAX_INITIALIZER_LINES  = 30"                                                  >> $@; \
 $(ECHO) "SHOW_USED_FILES        = YES"                                                 >> $@; \
 $(ECHO) "SHOW_DIRECTORIES       = YES"                                                 >> $@; \
 $(ECHO) "FILE_VERSION_FILTER    = "                                                    >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options related to warning and progress messages"             >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "QUIET                  = NO"                                                  >> $@; \
 $(ECHO) "WARNINGS               = YES"                                                 >> $@; \
 $(ECHO) "WARN_IF_UNDOCUMENTED   = YES"                                                 >> $@; \
 $(ECHO) "WARN_IF_DOC_ERROR      = YES"                                                 >> $@; \
 $(ECHO) "WARN_NO_PARAMDOC       = YES"                                                 >> $@; \
 $(ECHO) "WARN_FORMAT            = \"\$$file:\$$line: \$$text\""                        >> $@; \
 $(ECHO) "WARN_LOGFILE           = $(ERR_PATH)\doxygen.err"                             >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options related to the input files"                           >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "INPUT                  = $(DOXYGEN_INPUT)"                                    >> $@; \
 $(ECHO) "INPUT_ENCODING         = UTF-8"                                               >> $@; \
 $(ECHO) "FILE_PATTERNS          = *.h \\"                                              >> $@; \
 $(ECHO) "                         *.c"                                                 >> $@; \
 $(ECHO) "RECURSIVE              = NO"                                                  >> $@; \
 $(ECHO) "EXCLUDE                = "                                                    >> $@; \
 $(ECHO) "EXCLUDE_SYMLINKS       = NO"                                                  >> $@; \
 $(ECHO) "EXCLUDE_PATTERNS       = "                                                    >> $@; \
 $(ECHO) "EXCLUDE_SYMBOLS        = "                                                    >> $@; \
 $(ECHO) "EXAMPLE_PATH           = "                                                    >> $@; \
 $(ECHO) "EXAMPLE_PATTERNS       = "                                                    >> $@; \
 $(ECHO) "EXAMPLE_RECURSIVE      = NO"                                                  >> $@; \
 $(ECHO) "IMAGE_PATH             = $(CMD_PATH)/doxygen/images"                          >> $@; \
 $(ECHO) "INPUT_FILTER           = "                                                    >> $@; \
 $(ECHO) "FILTER_PATTERNS        = "                                                    >> $@; \
 $(ECHO) "FILTER_SOURCE_FILES    = NO"                                                  >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options related to source browsing"                           >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "SOURCE_BROWSER         = YES"                                                 >> $@; \
 $(ECHO) "INLINE_SOURCES         = YES"                                                 >> $@; \
 $(ECHO) "STRIP_CODE_COMMENTS    = YES"                                                 >> $@; \
 $(ECHO) "REFERENCED_BY_RELATION = YES"                                                 >> $@; \
 $(ECHO) "REFERENCES_RELATION    = YES"                                                 >> $@; \
 $(ECHO) "REFERENCES_LINK_SOURCE = YES"                                                 >> $@; \
 $(ECHO) "USE_HTAGS              = NO"                                                  >> $@; \
 $(ECHO) "VERBATIM_HEADERS       = YES"                                                 >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options related to the alphabetical class index"              >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "ALPHABETICAL_INDEX     = YES"                                                 >> $@; \
 $(ECHO) "COLS_IN_ALPHA_INDEX    = 5"                                                   >> $@; \
 $(ECHO) "IGNORE_PREFIX          = "                                                    >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options related to the HTML output"                           >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "GENERATE_HTML          = YES"                                                 >> $@; \
 $(ECHO) "HTML_OUTPUT            = docs\html"                                           >> $@; \
 $(ECHO) "HTML_FILE_EXTENSION    = .html"                                               >> $@; \
 $(ECHO) "HTML_HEADER            = $(CMD_PATH)/doxygen/header.txt"                      >> $@; \
 $(ECHO) "HTML_FOOTER            = $(CMD_PATH)/doxygen/footer.txt"                      >> $@; \
 $(ECHO) "HTML_STYLESHEET        = $(CMD_PATH)/doxygen/vector.css"                      >> $@; \
 $(ECHO) "HTML_ALIGN_MEMBERS     = YES"                                                 >> $@; \
 $(ECHO) "GENERATE_HTMLHELP      = YES"                                                 >> $@; \
 $(ECHO) "GENERATE_DOCSET        = NO"                                                  >> $@; \
 $(ECHO) "DOCSET_FEEDNAME        = Doxygen generated docs"                              >> $@; \
 $(ECHO) "DOCSET_BUNDLE_ID       = org.doxygen.Project"                                 >> $@; \
 $(ECHO) "HTML_DYNAMIC_SECTIONS  = NO"                                                  >> $@; \
 $(ECHO) "CHM_FILE               = .\$(PROJECT_NAME).chm"                               >> $@; \
 $(ECHO) "HHC_LOCATION           = \"C:/Programme/HTML Help Workshop/hhc.exe\""         >> $@; \
 $(ECHO) "GENERATE_CHI           = NO"                                                  >> $@; \
 $(ECHO) "BINARY_TOC             = NO"                                                  >> $@; \
 $(ECHO) "TOC_EXPAND             = NO"                                                  >> $@; \
 $(ECHO) "DISABLE_INDEX          = NO"                                                  >> $@; \
 $(ECHO) "ENUM_VALUES_PER_LINE   = 1"                                                   >> $@; \
 $(ECHO) "GENERATE_TREEVIEW      = YES"                                                 >> $@; \
 $(ECHO) "TREEVIEW_WIDTH         = 250"                                                 >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options related to the LaTeX output"                          >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "GENERATE_LATEX         = NO"                                                  >> $@; \
 $(ECHO) "LATEX_OUTPUT           = docs\latex"                                          >> $@; \
 $(ECHO) "LATEX_CMD_NAME         = latex"                                               >> $@; \
 $(ECHO) "MAKEINDEX_CMD_NAME     = makeindex"                                           >> $@; \
 $(ECHO) "COMPACT_LATEX          = NO"                                                  >> $@; \
 $(ECHO) "PAPER_TYPE             = a4wide"                                              >> $@; \
 $(ECHO) "EXTRA_PACKAGES         = "                                                    >> $@; \
 $(ECHO) "LATEX_HEADER           = "                                                    >> $@; \
 $(ECHO) "PDF_HYPERLINKS         = NO"                                                  >> $@; \
 $(ECHO) "USE_PDFLATEX           = NO"                                                  >> $@; \
 $(ECHO) "LATEX_BATCHMODE        = NO"                                                  >> $@; \
 $(ECHO) "LATEX_HIDE_INDICES     = NO"                                                  >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options related to the RTF output"                            >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "GENERATE_RTF           = NO"                                                  >> $@; \
 $(ECHO) "RTF_OUTPUT             = docs\rtf"                                            >> $@; \
 $(ECHO) "COMPACT_RTF            = NO"                                                  >> $@; \
 $(ECHO) "RTF_HYPERLINKS         = YES"                                                 >> $@; \
 $(ECHO) "RTF_STYLESHEET_FILE    = "                                                    >> $@; \
 $(ECHO) "RTF_EXTENSIONS_FILE    = "                                                    >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options related to the man page output"                       >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "GENERATE_MAN           = NO"                                                  >> $@; \
 $(ECHO) "MAN_OUTPUT             = docs\man"                                            >> $@; \
 $(ECHO) "MAN_EXTENSION          = .3"                                                  >> $@; \
 $(ECHO) "MAN_LINKS              = NO"                                                  >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options related to the XML output"                            >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "GENERATE_XML           = NO"                                                  >> $@; \
 $(ECHO) "XML_OUTPUT             = docs\xml"                                            >> $@; \
 $(ECHO) "XML_SCHEMA             = "                                                    >> $@; \
 $(ECHO) "XML_DTD                = "                                                    >> $@; \
 $(ECHO) "XML_PROGRAMLISTING     = YES"                                                 >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options for the AutoGen Definitions output"                   >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "GENERATE_AUTOGEN_DEF   = NO"                                                  >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# configuration options related to the Perl module output"                    >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "GENERATE_PERLMOD       = NO"                                                  >> $@; \
 $(ECHO) "PERLMOD_LATEX          = NO"                                                  >> $@; \
 $(ECHO) "PERLMOD_PRETTY         = YES"                                                 >> $@; \
 $(ECHO) "PERLMOD_MAKEVAR_PREFIX = "                                                    >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# Configuration options related to the preprocessor   "                       >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "ENABLE_PREPROCESSING   = YES"                                                 >> $@; \
 $(ECHO) "MACRO_EXPANSION        = YES"                                                 >> $@; \
 $(ECHO) "EXPAND_ONLY_PREDEF     = NO"                                                  >> $@; \
 $(ECHO) "SEARCH_INCLUDES        = YES"                                                 >> $@; \
 $(ECHO) "INCLUDE_PATH           = $(DOXYGEN_INCLUDE)"                                  >> $@; \
 $(ECHO) "INCLUDE_FILE_PATTERNS  = *.h"                                                 >> $@; \
 $(ECHO) "PREDEFINED             = $(DEP_DEFINES)"                                      >> $@; \
 $(ECHO) "EXPAND_AS_DEFINED      = "                                                    >> $@; \
 $(ECHO) "SKIP_FUNCTION_MACROS   = NO"                                                  >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# Configuration::additions related to external references  "                  >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "TAGFILES               = "                                                    >> $@; \
 $(ECHO) "GENERATE_TAGFILE       = "                                                    >> $@; \
 $(ECHO) "ALLEXTERNALS           = NO"                                                  >> $@; \
 $(ECHO) "EXTERNAL_GROUPS        = YES"                                                 >> $@; \
 $(ECHO) "PERL_PATH              = "                                                    >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# Configuration options related to the dot tool   "                           >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "CLASS_DIAGRAMS         = YES"                                                 >> $@; \
 $(ECHO) "MSCGEN_PATH            = $(subst /,\\,$(CMD_PATH)/doxygen/mscgen)"            >> $@; \
 $(ECHO) "HIDE_UNDOC_RELATIONS   = YES"                                                 >> $@; \
 $(ECHO) "HAVE_DOT               = YES"                                                 >> $@; \
 $(ECHO) "CLASS_GRAPH            = YES"                                                 >> $@; \
 $(ECHO) "COLLABORATION_GRAPH    = YES"                                                 >> $@; \
 $(ECHO) "GROUP_GRAPHS           = YES"                                                 >> $@; \
 $(ECHO) "UML_LOOK               = YES"                                                 >> $@; \
 $(ECHO) "TEMPLATE_RELATIONS     = YES"                                                 >> $@; \
 $(ECHO) "INCLUDE_GRAPH          = YES"                                                 >> $@; \
 $(ECHO) "INCLUDED_BY_GRAPH      = YES"                                                 >> $@; \
 $(ECHO) "CALL_GRAPH             = YES"                                                 >> $@; \
 $(ECHO) "CALLER_GRAPH           = YES"                                                 >> $@; \
 $(ECHO) "GRAPHICAL_HIERARCHY    = YES"                                                 >> $@; \
 $(ECHO) "DIRECTORY_GRAPH        = YES"                                                 >> $@; \
 $(ECHO) "DOT_IMAGE_FORMAT       = png"                                                 >> $@; \
 $(ECHO) "DOT_PATH               = $(subst /,\\,$(CMD_PATH)/doxygen)"                   >> $@; \
 $(ECHO) "DOTFILE_DIRS           = "                                                    >> $@; \
 $(ECHO) "DOT_GRAPH_MAX_NODES    = 50"                                                  >> $@; \
 $(ECHO) "MAX_DOT_GRAPH_DEPTH    = 1000"                                                >> $@; \
 $(ECHO) "DOT_TRANSPARENT        = YES"                                                 >> $@; \
 $(ECHO) "DOT_MULTI_TARGETS      = NO"                                                  >> $@; \
 $(ECHO) "GENERATE_LEGEND        = YES"                                                 >> $@; \
 $(ECHO) "DOT_CLEANUP            = YES"                                                 >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "# Configuration::additions related to the search engine   "                   >> $@; \
 $(ECHO) "#---------------------------------------------------------------------------" >> $@; \
 $(ECHO) "SEARCHENGINE           = NO"                                                  >> $@; \
 $(ECHO) "...done";                                                                            \
 $(ECHO) "";

##############################################################################
# Resource information generation
##############################################################################
#-----------------------------------------------------------------------------
# List of files, which contain the resource information
#-----------------------------------------------------------------------------
LST_LIST = \
  $(if $(findstring $(RESOURCE_FILE),LIST), $(LST_PATH)/*.$(RESOURCE_FILE_EXT), \
    $(if $(findstring $(RESOURCE_FILE),MAP),                                    \
      $(PROJECT_NAME).$(RESOURCE_FILE_EXT)                                      \
    ,                                                                           \
      RESOURCE_NOT_SET                                                          \
    )                                                                           \
  )

#-----------------------------------------------------------------------------
# General storage location for resource information
#-----------------------------------------------------------------------------
RESOURCE_REPOSITORY  = \\vistrfs1\vgroup\PES\30_ProductManagement\_EmbeddedSwRessourceNeeds

#-----------------------------------------------------------------------------
# Resource information generation rules
#-----------------------------------------------------------------------------
RESOURCE_NOT_SET:
	@$(ECHO) "Resource is not set correctly or resource target not supported for selected platform.";

fetch-memory-info-meta.txt:
	@$(ECHO) "COMPILER_MANUFACTURER:"   '$(subst \,\\, $(COMPILER_MANUFACTURER))'  > $@; \
  $(ECHO) "PROJECT_DIR:"             '$(subst \,\\, $(subst \\,\,$(CURDIR)))'   >> $@; \
  $(ECHO) "PLATFORM:"                '$(subst \,\\, $(PLATFORM))'               >> $@; \
  $(ECHO) "EMULATOR:"                '$(subst \,\\, $(EMULATOR))'               >> $@; \
  $(ECHO) "EVA_BOARD:"               '$(subst \,\\, $(EVA_BOARD))'              >> $@; \
  $(ECHO) "DERIVATIVE:"              '$(subst \,\\, $(DERIVATIVE))'             >> $@; \
  $(ECHO) "PROJECT_NAME:"            '$(subst \,\\, $(PROJECT_NAME))'           >> $@; \
  $(ECHO) "CC_VERSION_STRING:"       '$(subst \,\\, $(CC_VERSION_STRING))'      >> $@; \
  $(ECHO) "CFLAGS_ADDITIONAL_POST:"  '$(subst \,\\, $(CFLAGS))'                 >> $@; \
  $(ECHO) "CVERSION_STRING:"         '$(subst \,\\, $(CVERSION_STRING))'        >> $@; \
  $(ECHO) "LDFLAGS_ADDITIONAL_POST:" '$(subst \,\\, $(LDFLAGS))'                >> $@; \
  $(ECHO) "LDVERSION_STRING:"        '$(subst \,\\, $(LDVERSION_STRING))'       >> $@; \
  $(ECHO) "ASFLAGS_ADDITIONAL_POST:" '$(subst \,\\, $(ASFLAGS))'                >> $@; \
  $(ECHO) "ASVERSION_STRING:"        '$(subst \,\\, $(ASVERSION_STRING))'       >> $@; \
  $(ECHO) "EXT_T1_VERSION_STRING:"   '$(subst \,\\, $(EXT_T1_VERSION_STRING))'  >> $@; \
  $(ECHO) "EXT_T1_FLAGS:"            '$(subst \,\\, $(EXT_T1_FLAGS))'           >> $@; \
  $(ECHO) "EXT_T2_VERSION_STRING:"   '$(subst \,\\, $(EXT_T2_VERSION_STRING))'  >> $@; \
  $(ECHO) "EXT_T2_FLAGS:"            '$(subst \,\\, $(EXT_T2_FLAGS))'           >> $@; \
  if [ -n "$(FROM_VINFO_CBD)" ] ; then                                                 \
  $(ECHO) "FROM_VINFO_CBD:"          '$(subst \,\\, $(FROM_VINFO_CBD))'         >> $@; \
  fi;                                                                                  \
  if [ -n "$(FROM_VINFO_SIP)" ] ; then                                                 \
  $(ECHO) "FROM_VINFO_SIP:"          '$(subst \,\\, $(FROM_VINFO_SIP))'         >> $@; \
  fi;                                                                                  \
  if [ -n "$(FROM_VINFO_OEM)" ] ; then                                                 \
  $(ECHO) "FROM_VINFO_OEM:"          '$(subst \,\\, $(FROM_VINFO_OEM))'         >> $@; \
  fi;                                                                                  \
  if [ -n "$(FROM_VINFO_CONTROLLER)" ] ; then                                          \
  $(ECHO) "FROM_VINFO_CONTROLLER:"   '$(subst \,\\, $(FROM_VINFO_CONTROLLER))'  >> $@; \
  fi;                                                                                  \
  if [ -n "$(FROM_VINFO_COMPILER)" ] ; then                                            \
  $(ECHO) "FROM_VINFO_COMPILER:"     '$(subst \,\\, $(FROM_VINFO_COMPILER))'    >> $@; \
  fi;                                                                                  \
  if [ -n "$(FROM_VINFO_SLP)" ] ; then                                                 \
  $(ECHO) "FROM_VINFO_SLP:"          '$(subst \,\\, $(FROM_VINFO_SLP))'         >> $@; \
  fi;                                                                                  \
  if [ -n "$(FROM_VINFO_CANCELL)" ] ; then                                             \
  $(ECHO) "FROM_VINFO_CANCELL:"      '$(subst \,\\, $(FROM_VINFO_CANCELL))'     >> $@; \
  fi;

fetch-memory-info.awk: force
	@$(ECHO) '$(RESOURCE_FETCH_SCRIPT)'                                                                                > $@; \
 $(ECHO) "BEGIN {"                                                                                                  >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# Print the header of the outputted file"                                                                 >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "_additional_module_lst = \"$(subst \,\\\\,$(ADDITIONAL_OBJECTS)) $(subst \,\\\\,$(APP_SOURCE_LST))\";"    >> $@; \
 $(ECHO) "  if (XML) {"                                                                                             >> $@; \
 $(ECHO) "    print \"<?xml version='1.0'?>\";"                                                                     >> $@; \
 $(ECHO) "    print \"<memory-usage>\"; # root tag"                                                                 >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  while (getline < \"fetch-memory-info-meta.txt\")"                                                       >> $@; \
 $(ECHO) "  {"                                                                                                      >> $@; \
 $(ECHO) "    _colon_index = index(\$$0, \":\");"                                                                   >> $@; \
 $(ECHO) "    if (_colon_index <= 0) {"                                                                             >> $@; \
 $(ECHO) "      continue;"                                                                                          >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "    _key = substr(\$$0, 0, _colon_index - 1);"                                                            >> $@; \
 $(ECHO) "    _val = substr(\$$0, _colon_index + 1);"                                                               >> $@; \
 $(ECHO) "    _val = trim(_val);"                                                                                   >> $@; \
 $(ECHO) "    if (_val ~ /^[-=]/) {"                                                                                >> $@; \
 $(ECHO) "      _val = \"'\" _val;"                                                                                 >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "    if (XML) { # translate some entities"                                                                 >> $@; \
 $(ECHO) "      gsub(\">\", \"\\\\&gt;\", _val);"                                                                   >> $@; \
 $(ECHO) "      gsub(\"<\", \"\\\\&lt;\", _val);"                                                                   >> $@; \
 $(ECHO) "      gsub(\"&\", \"\\\\&amp;\", _val);"                                                                  >> $@; \
 $(ECHO) "      gsub(\"\\\"\", \"\\\\&quot;\", _val);"                                                              >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "    if (XML) {"                                                                                           >> $@; \
 $(ECHO) "      printf \"  <meta name=\\\"%s\\\">%s</meta>\\n\", _key, _val;"                                       >> $@; \
 $(ECHO) "    } else {"                                                                                             >> $@; \
 $(ECHO) "      printf \"%s\\t%s\\n\", _key, _val;"                                                                 >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "    if (_key == \"PROJECT_DIR\") {"                                                                       >> $@; \
 $(ECHO) "      match(_val, /^[C-Z]:\\\\usr\\\\distrib\\\\[^\\\\]+\\\\[^\\\\]+\\\\([^\\\\]+)\\\\([^\\\\]+)\\\\/,"   >> $@; \
 $(ECHO) "            _OEM_SLP);"                                                                                   >> $@; \
 $(ECHO) "      if (XML) {"                                                                                         >> $@; \
 $(ECHO) "        printf \"  <meta name=\\\"OEM\\\">%s</meta>\\n\", _OEM_SLP[1];"                                   >> $@; \
 $(ECHO) "        printf \"  <meta name=\\\"SLP\\\">%s</meta>\\n\", _OEM_SLP[2];"                                   >> $@; \
 $(ECHO) "      } else {"                                                                                           >> $@; \
 $(ECHO) "        printf \"OEM\\t%s\\n\", _OEM_SLP[1];"                                                             >> $@; \
 $(ECHO) "        printf \"SLP\\t%s\\n\", _OEM_SLP[2];"                                                             >> $@; \
 $(ECHO) "      }"                                                                                                  >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  printf \"\\n\";"                                                                                        >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# This section is called at the end of the whole script."                                                 >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "END {"                                                                                                    >> $@; \
 $(ECHO) "    if (DEBUG) {"                                                                                         >> $@; \
 $(ECHO) "        printf \"\\n\\n\"; # two empty lines"                                                             >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "  if (!XML) {"                                                                                            >> $@; \
 $(ECHO) "    print \"Module\\tcode\\tconst\\tRAM\\tInitRAM\";"                                                     >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  printEntries();"                                                                                        >> $@; \
 $(ECHO) "  if (XML) {"                                                                                             >> $@; \
 $(ECHO) "    print \"</memory-usage>\"; # root tag"                                                                >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# This API function is the most important one:"                                                           >> $@; \
 $(ECHO) "# It adds an entry to the internal list, which is printed at the end."                                    >> $@; \
 $(ECHO) "# @param string moduleName: Contains the name of the module you want to add"                              >> $@; \
 $(ECHO) "#           byteSize."                                                                                    >> $@; \
 $(ECHO) "# @param string memoryType: Contains the memory type you want to add byteSize."                           >> $@; \
 $(ECHO) "#           The memory type is mapped by the memoryTable to the according"                                >> $@; \
 $(ECHO) "#           memory section (ram, rom, const)."                                                            >> $@; \
 $(ECHO) "# @param string byteSize: Contains the size of memory in bytes. The format must"                          >> $@; \
 $(ECHO) "#           be either hexadecimal or decimal. Number with a leading '0x' or a"                            >> $@; \
 $(ECHO) "#           trailing 'h' are autodetected as a hexadecimal value."                                        >> $@; \
 $(ECHO) "# @param bool isHex: OPTIONAL: If set to 1 the param byteSize will be treated as"                         >> $@; \
 $(ECHO) "#           a hexadecimal string. If 0 (standard) the function tries to auto-"                            >> $@; \
 $(ECHO) "#           detect if byteSize is a hex or a decimal value."                                              >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function addEntry(moduleName, memoryType, byteSize, isHex) {"                                             >> $@; \
 $(ECHO) "  moduleName = trim(moduleName);"                                                                         >> $@; \
 $(ECHO) "  memoryType = trim(memoryType);"                                                                         >> $@; \
 $(ECHO) "  byteSize   = trim(byteSize);"                                                                           >> $@; \
 $(ECHO) "  # If byteSize has a trailing 'h' or a leading '0x' hexformat is autodetected"                           >> $@; \
 $(ECHO) "  if (isHex || (byteSize ~ /^0x/) || (byteSize ~ /h\$$/)) {"                                              >> $@; \
 $(ECHO) "    byteSize = hex2dec(byteSize);"                                                                        >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  "                                                                                                       >> $@; \
 $(ECHO) "  mappedMemoryType  = parseMemoryType(memoryType);"                                                       >> $@; \
 $(ECHO) "  moduleName        = pathToModule(moduleName);"                                                          >> $@; \
 $(ECHO) "  "                                                                                                       >> $@; \
 $(ECHO) "  if (DEBUG) {"                                                                                           >> $@; \
 $(ECHO) "    printf \"%5d Adding: %12s %14s -> %6s 0x%04X (%d)\\n\", FNR, moduleName, \\"                          >> $@; \
 $(ECHO) "                      memoryType, mappedMemoryType, byteSize, byteSize;"                                  >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  if (mappedMemoryType == \"ignore\") {"                                                                  >> $@; \
 $(ECHO) "    return;"                                                                                              >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  _private_array_modules[moduleName, mappedMemoryType] += byteSize;"                                      >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# The function decides, depending on the current file and the processing state"                           >> $@; \
 $(ECHO) "# (set by startProcessing() and stopProcessing()), if processing has to"                                  >> $@; \
 $(ECHO) "# continue or jump to next record."                                                                       >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function process() {"                                                                                     >> $@; \
 $(ECHO) "  if (FNR == 1 && DEBUG) {"                                                                               >> $@; \
 $(ECHO) "    print  \"\"; # print empty line"                                                                      >> $@; \
 $(ECHO) "    printf \"!Begin with File \\\"%s\\\"\\n\", FILENAME;"                                                 >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  if (_private_processingState != FILENAME) { # inactive"                                                 >> $@; \
 $(ECHO) "    next;"                                                                                                >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# This function starts the processing for the current file. After calling"                                >> $@; \
 $(ECHO) "# the processing will begin and no further records are skipped."                                          >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function startProcessing() {"                                                                             >> $@; \
 $(ECHO) "  if ((_private_processingState != FILENAME) && DEBUG) {"                                                 >> $@; \
 $(ECHO) "    printf \"!Start processing file \\\"%s\\\" at line %d\\n\", FILENAME, FNR;"                           >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  _private_processingState = FILENAME;"                                                                   >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# This function is the complement to startProcessing() and stops the processing."                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function stopProcessing() {"                                                                              >> $@; \
 $(ECHO) "  if (_private_processingState == FILENAME) { # We started processing"                                    >> $@; \
 $(ECHO) "    if (DEBUG) {"                                                                                         >> $@; \
 $(ECHO) "      printf \"!Stopping processing file \\\"%s\\\" at line %d\\n\", FILENAME, FNR;"                      >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "    _private_processingState = 0;"                                                                        >> $@; \
 $(ECHO) "    nextfile; # We're done for this file. Go to the next one"                                             >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# This function converts a hexadecimal number to a decimal one."                                          >> $@; \
 $(ECHO) "# @param string hexStr: The string which has to be converted. Dont need to have"                          >> $@; \
 $(ECHO) "#             leading '0x'. Can have a trailing 'h'."                                                     >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function hex2dec(hexStr) {"                                                                               >> $@; \
 $(ECHO) "  if (hexStr !~ /^0x/) {"                                                                                 >> $@; \
 $(ECHO) "    hexStr = \"0x\" hexStr;"                                                                              >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  if (hexStr ~ /h\$$/) {"                                                                                 >> $@; \
 $(ECHO) "    gsub(/h\$$/, \"\", hexStr); # Strip trailing 'h'"                                                     >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  return strtonum(hexStr);"                                                                               >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# This function prints the internal array which contains the memory information"                          >> $@; \
 $(ECHO) "# The output format is a tab seperated list with the order:"                                              >> $@; \
 $(ECHO) "# moduleName, sizeCode, sizeConst, sizeRam"                                                               >> $@; \
 $(ECHO) "# @param NONE!"                                                                                           >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function printEntries(j, i, n, ind, keyArr, key, moduleName, printedModules,"                             >> $@; \
 $(ECHO) "                      ram, code, const, iram, totaliram)"                                                 >> $@; \
 $(ECHO) "{"                                                                                                        >> $@; \
 $(ECHO) "  if (XML) {"                                                                                             >> $@; \
 $(ECHO) "    print \"  <modules>\";"                                                                               >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  j = 1;"                                                                                                 >> $@; \
 $(ECHO) "  for (i in _private_array_modules) {"                                                                    >> $@; \
 $(ECHO) "    ind[j] = i; # index value becomes element value"                                                      >> $@; \
 $(ECHO) "    j++;"                                                                                                 >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  if( j == 1 ) {"                                                                                         >> $@; \
 $(ECHO) "    error(\"Your AWK Script never called addEntry(). Please check Makefile Script.\");"                   >> $@; \
 $(ECHO) "    n = 0;"                                                                                               >> $@; \
 $(ECHO) "  } else {"                                                                                               >> $@; \
 $(ECHO) "    n = asort(ind); # index values are now sorted"                                                        >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  gsub(/\\\\ /, \"~~~\", _additional_module_lst);"                                                        >> $@; \
 $(ECHO) "  _number_additional_modulese = split(_additional_module_lst, _tmp, \"[ ]+\");"                           >> $@; \
 $(ECHO) "  for( i = 1; i <= _number_additional_modulese; i++ ) {"                                                  >> $@; \
 $(ECHO) "    gsub(/~~~/, \" \", _tmp[i]);"                                                                         >> $@; \
 $(ECHO) "    _additional_module_array[pathToModule(_tmp[i])] = 1;"                                                 >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  for (i = 1; i <= n; i++) {"                                                                             >> $@; \
 $(ECHO) "    key = ind[i];"                                                                                        >> $@; \
 $(ECHO) "    split(key, keyArr, SUBSEP);"                                                                          >> $@; \
 $(ECHO) "    moduleName = keyArr[1];"                                                                              >> $@; \
 $(ECHO) "    if( moduleName in _additional_module_array ) {"                                                       >> $@; \
 $(ECHO) "      _private_array_modules[moduleName, \"__ISADD__\"] = 1;"                                             >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  print \"\";"                                                                                            >> $@; \
 $(ECHO) "  printModuleSummary(ind, n, 0);"                                                                         >> $@; \
 $(ECHO) "  print \"\"; print \"\";"                                                                                >> $@; \
 $(ECHO) "  printModuleSummary(ind, n, 1);"                                                                         >> $@; \
 $(ECHO) "  if (XML) {"                                                                                             >> $@; \
 $(ECHO) "    print \"  </modules>\";"                                                                              >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) "function printModuleSummary(ind, n, isAdditional) {"                                                      >> $@; \
 $(ECHO) "  if( isAdditional ) {"                                                                                   >> $@; \
 $(ECHO) "    if( XML ) {"                                                                                          >> $@; \
 $(ECHO) "      print \"<additional>\";"                                                                            >> $@; \
 $(ECHO) "    } else {"                                                                                             >> $@; \
 $(ECHO) "      print \"Additonal modules:\";"                                                                      >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "  } else {"                                                                                               >> $@; \
 $(ECHO) "    if( XML ) {"                                                                                          >> $@; \
 $(ECHO) "      print \"<core>\";"                                                                                  >> $@; \
 $(ECHO) "    } else {"                                                                                             >> $@; \
 $(ECHO) "      print \"Core modules:\";"                                                                           >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  totaliram = 0;"                                                                                         >> $@; \
 $(ECHO) "  totalram = 0;"                                                                                          >> $@; \
 $(ECHO) "  totalrom = 0;"                                                                                          >> $@; \
 $(ECHO) "  totalcode = 0;"                                                                                         >> $@; \
 $(ECHO) "  for (i = 1; i <= n; i++) {"                                                                             >> $@; \
 $(ECHO) "    key = ind[i];"                                                                                        >> $@; \
 $(ECHO) "    split(key, keyArr, SUBSEP);"                                                                          >> $@; \
 $(ECHO) "    moduleName = keyArr[1];"                                                                              >> $@; \
 $(ECHO) "    if( isAdditional != _private_array_modules[moduleName, \"__ISADD__\"] ) {"                            >> $@; \
 $(ECHO) "      continue;"                                                                                          >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "    if ( !(moduleName in printedModules) ) {"                                                             >> $@; \
 $(ECHO) "      ram = _private_array_modules[moduleName, \"ram\"]+0;"                                               >> $@; \
 $(ECHO) "      iram = _private_array_modules[moduleName, \"iram\"]+0;"                                             >> $@; \
 $(ECHO) "      code = _private_array_modules[moduleName, \"code\"]+0;"                                             >> $@; \
 $(ECHO) "      const = _private_array_modules[moduleName, \"const\"]+0;"                                           >> $@; \
 $(ECHO) "      totaliram += iram;"                                                                                 >> $@; \
 $(ECHO) "      totalcode += code;"                                                                                 >> $@; \
 $(ECHO) "      totalram  += ram;"                                                                                  >> $@; \
 $(ECHO) "      totalrom  += const;"                                                                                >> $@; \
 $(ECHO) "      printedModules[moduleName] = 1;"                                                                    >> $@; \
 $(ECHO) "      if (XML)"                                                                                           >> $@; \
 $(ECHO) "      {"                                                                                                  >> $@; \
 $(ECHO) "        print \"    <module name=\\\"\" moduleName \"\\\">\";"                                            >> $@; \
 $(ECHO) "        print \"      <code>\" code \"</code>\";"                                                         >> $@; \
 $(ECHO) "        print \"      <const>\" const \"</const>\";"                                                      >> $@; \
 $(ECHO) "        print \"      <ram>\" ram \"</ram>\";"                                                            >> $@; \
 $(ECHO) "        print \"      <iram>\" iram \"</iram>\";"                                                         >> $@; \
 $(ECHO) "        print \"    </module>\";"                                                                         >> $@; \
 $(ECHO) "      }"                                                                                                  >> $@; \
 $(ECHO) "      else"                                                                                               >> $@; \
 $(ECHO) "      {"                                                                                                  >> $@; \
 $(ECHO) "        print moduleName \"\\t\" code \"\\t\" const \"\\t\" ram \"\\t\" iram;"                            >> $@; \
 $(ECHO) "      }"                                                                                                  >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  if( !XML ) {"                                                                                           >> $@; \
 $(ECHO) "    print \"Total:\" \"\\t\" totalcode \"\\t\" totalrom \"\\t\" totalram \"\\t\" totaliram;"              >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  if( totaliram > 0 ) {"                                                                                  >> $@; \
 $(ECHO) "    error(\"Warning: \" totaliram \" bytes initalized RAM is used!\");"                                   >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  if( isAdditional ) {"                                                                                   >> $@; \
 $(ECHO) "    if( XML ) {"                                                                                          >> $@; \
 $(ECHO) "      print \"</additional>\";"                                                                           >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "  } else {"                                                                                               >> $@; \
 $(ECHO) "    if( XML ) {"                                                                                          >> $@; \
 $(ECHO) "      print \"</core>\";"                                                                                 >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# Handles input strings like \"C:\\path\\to\\file.ext\" and filters out 'file'"                           >> $@; \
 $(ECHO) "# Strips out content within parentheses () and brackets [], but only if it"                               >> $@; \
 $(ECHO) "# wouldnt result in a blank string."                                                                      >> $@; \
 $(ECHO) "# Hint: Bracket: []        Parentheses: ()"                                                               >> $@; \
 $(ECHO) "# @param string pathname: Contains the path which is analysed"                                            >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function pathToModule(pathname) {"                                                                        >> $@; \
 $(ECHO) "  pathname = trim(pathname);"                                                                             >> $@; \
 $(ECHO) "  if (pathname ~ /^\\(+.*\\)+\$$/) { # only if pathname starts AND ends with ()"                          >> $@; \
 $(ECHO) "      sub(/^\\(+/, \"\", pathname); # Strip leading ("                                                    >> $@; \
 $(ECHO) "      sub(/\\)+\$$/, \"\", pathname); # Strip trailing )"                                                 >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  if (pathname ~ /^\\[+.*\\]+\$$/) { # only if pathname starts AND ends with []"                          >> $@; \
 $(ECHO) "      sub(/^\\[+/, \"\", pathname); # Strip leading ["                                                    >> $@; \
 $(ECHO) "      sub(/\\]+\$$/, \"\", pathname); # Strip trailing ]"                                                 >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  pathname = trim(pathname);"                                                                             >> $@; \
 $(ECHO) "  sub(/\\(.*\\)/,   \"\", pathname); # Strip contents within parentheses"                                 >> $@; \
 $(ECHO) "  sub(/\\[.*\\]/,   \"\", pathname); # Strip contents within brackets"                                    >> $@; \
 $(ECHO) "  sub(/.*[\\/\\\\]/, \"\", pathname); # Strip the path"                                                   >> $@; \
 $(ECHO) "  sub(/\\.[^.]+\$$/, \"\", pathname); # Strip file extension"                                             >> $@; \
 $(ECHO) "  return pathname;"                                                                                       >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# This function takes an string which is treated as a memory information and"                             >> $@; \
 $(ECHO) "# maps it to the according memory by the memoryTable array defined at the"                                >> $@; \
 $(ECHO) "# BEGIN{} section. If no regular expression from the memoryTable matches, an"                             >> $@; \
 $(ECHO) "# error is printed and the program is shutting down."                                                     >> $@; \
 $(ECHO) "# @see memoryTable[] at BEGIN{} section"                                                                  >> $@; \
 $(ECHO) "# @param string input: The string which should be mapped."                                                >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function parseMemoryType(input,     key, keyOrder, i, numberElements) {"                                  >> $@; \
 $(ECHO) "  numberElements = split(memoryTableOrder, keyOrder, \",\");"                                             >> $@; \
 $(ECHO) "  for (i = 1; i <= numberElements; i++) {"                                                                >> $@; \
 $(ECHO) "    key = keyOrder[i];"                                                                                   >> $@; \
 $(ECHO) "    if(memoryTable[key] == \"\") {"                                                                       >> $@; \
 $(ECHO) "      continue;"                                                                                          >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "    if (input ~ memoryTable[key]) {"                                                                      >> $@; \
 $(ECHO) "      return key;"                                                                                        >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "  if( _private_detected_wrong_input[input] != 1 ) { # We did not yet print"                               >> $@; \
 $(ECHO) "    _private_detected_wrong_input[input] = 1;"                                                            >> $@; \
 $(ECHO) "    if( _private_initial_print == 1 ) {"                                                                  >> $@; \
 $(ECHO) "      error(\"!Error: Other unknown input type: '\" input \"'\");"                                        >> $@; \
 $(ECHO) "    } else {"                                                                                             >> $@; \
 $(ECHO) "      error(\"--------------------------------------------------------------------\\n\" \\"               >> $@; \
 $(ECHO) "            \"!Error: Unable to handle input type '\" input \"'\\n\" \\"                                  >> $@; \
 $(ECHO) "            \"  Filename: '\" FILENAME \"' at line \" FNR \"\\n\" \\"                                     >> $@; \
 $(ECHO) "            \"!Modify your AWK - Script in your project Makefile. The script is\\n\" \\"                  >> $@; \
 $(ECHO) "            \"   located at the Makefile variable \\\"RESOURCE_FETCH_SCRIPT\\\".\\n\" \\"                 >> $@; \
 $(ECHO) "            \"!Check your array <<memoryTable>> in the BEGIN{} section.\\n\" \\"                          >> $@; \
 $(ECHO) "            \"  E.g. add '\" input \"' to memoryTable[\\\"ram\\\"] to map it to RAM.\\n\" \\"             >> $@; \
 $(ECHO) "            \"  I.e.: memoryTable[\\\"ram\\\"] = \\\"\" memoryTable[\"ram\"] \"|\" input \"\\\";\\n\" \\" >> $@; \
 $(ECHO) "            \"  To ignore '\" input \"', add it to memoryTable[\\\"ignore\\\"]:\\n\" \\"                  >> $@; \
 $(ECHO) "            \"  memoryTable[\\\"ignore\\\"] = \\\"\" memoryTable[\"ignore\"] \"|\" input \"\\\";\\n\" \\" >> $@; \
 $(ECHO) "            \"--------------------------------------------------------------------\\n\");"                >> $@; \
 $(ECHO) "    }"                                                                                                    >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  _private_initial_print = 1;"                                                                            >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# Small helper function to filter out a string enclosed in parentheses."                                  >> $@; \
 $(ECHO) "# @param string input: The input string which should be analysed"                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function getStringWithinParentheses(input,     tmpArr, tmpVar) {"                                         >> $@; \
 $(ECHO) "    if (match(input, /(\\(.+\\))/, tmpArr)) {"                                                            >> $@; \
 $(ECHO) "    tmpVar = tmpArr[1];"                                                                                  >> $@; \
 $(ECHO) "        gsub(/[\\(\\)]/, \"\", tmpVar); # strip off ( and )"                                              >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  return (tmpVar ~ /\\w/) ? tmpVar : input;"                                                              >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# Small helper function to filter out a string enclosed in brackets."                                     >> $@; \
 $(ECHO) "# @param string input: The input string which should be analysed"                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function getStringWithinBrackets(input,     tmpArr, tmpVar) {"                                            >> $@; \
 $(ECHO) "    if (match(input, /(\\[.+\\])/, tmpArr)) {"                                                            >> $@; \
 $(ECHO) "    tmpVar = tmpArr[1];"                                                                                  >> $@; \
 $(ECHO) "    gsub(/[\\[\\]]/, \"\", tmpVar); # strip off [ and ]"                                                  >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  return (tmpVar ~ /\\w/) ? tmpVar : input;"                                                              >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# Small helper function to trim a string. Removes trailing and leading space/tab"                         >> $@; \
 $(ECHO) "# @param string input: The input string which has to be trimmed"                                          >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function trim(str) {"                                                                                     >> $@; \
 $(ECHO) "    gsub(/^[ \\t]+/, \"\", str); # Strip leading  space/tap (ltrim)"                                      >> $@; \
 $(ECHO) "    gsub(/[ \\t]+\$$/, \"\", str); # Strip trailing space/tab (rtrim)"                                    >> $@; \
 $(ECHO) "    return str;"                                                                                          >> $@; \
 $(ECHO) "}"                                                                                                        >> $@; \
 $(ECHO) ""                                                                                                         >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "# Small helper function to print an error."                                                               >> $@; \
 $(ECHO) "# @param string input: The input string which has to printed."                                            >> $@; \
 $(ECHO) "################################################################################"                         >> $@; \
 $(ECHO) "function error(str) {"                                                                                    >> $@; \
 $(ECHO) "  if (XML) { # translate some entities"                                                                   >> $@; \
 $(ECHO) "    gsub(\">\", \"\\\\&gt;\", str);"                                                                      >> $@; \
 $(ECHO) "    gsub(\"<\", \"\\\\&lt;\", str);"                                                                      >> $@; \
 $(ECHO) "    gsub(\"&\", \"\\\\&amp;\", str);"                                                                     >> $@; \
 $(ECHO) "    gsub(\"\\\"\", \"\\\\&quot;\", str);"                                                                 >> $@; \
 $(ECHO) "    print \"<error>\";"                                                                                   >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "  print str;"                                                                                             >> $@; \
 $(ECHO) "  if (XML) {"                                                                                             >> $@; \
 $(ECHO) "    print \"</error>\";"                                                                                  >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "# Additional output to console to make processing errors more obvious."                                   >> $@; \
 $(ECHO) "  if (XML) {"                                                                                             >> $@; \
 $(ECHO) "    print str > \"/dev/stderr\";"                                                                         >> $@; \
 $(ECHO) "  }"                                                                                                      >> $@; \
 $(ECHO) "}"                                                                                                        >> $@;

CLEAN_RESOURCE_FILENAME = $(subst $(_OPEN_PAREN),,$(subst $(_CLOSE_PAREN),,$(RESOURCE_FILENAME)))

resource: $(LST_LIST) $(if $(findstring $(LST_LIST),RESOURCE_NOT_SET),,fetch-memory-info-meta.txt fetch-memory-info.awk)
	@if [ "$(strip $(LST_LIST))" != "RESOURCE_NOT_SET" ] ; then                                                     \
    if [ -f $(GAWK) ] ; then                                                                                            \
      $(GAWK) --re-interval -v DEBUG=0 -f fetch-memory-info.awk $(LST_LIST)                                             \
          > $(LOG_PATH)/$(PROJECT_NAME)_resource.xls;                                                                   \
      $(GAWK) --re-interval -v   XML=1 -f fetch-memory-info.awk $(LST_LIST)                                             \
          > $(LOG_PATH)/$(PROJECT_NAME)_resource.xml;                                                                   \
      if [ -n "$(CLEAN_RESOURCE_FILENAME)" ] ; then                                                                     \
        $(ECHO) "Generated files: $(LOG_PATH)/$(CLEAN_RESOURCE_FILENAME).Resource.xml";                                 \
        $(ECHO) "                 $(LOG_PATH)/$(CLEAN_RESOURCE_FILENAME).Resource.xls";                                 \
        $(ECHO) "                 $(subst \,\\,$(RESOURCE_REPOSITORY)\$(RESOURCE_TARGETDIR)\$(CLEAN_RESOURCE_FILENAME)).Resource.xml"; \
        $(MV) $(LOG_PATH)/$(PROJECT_NAME)_resource.xls $(LOG_PATH)/$(CLEAN_RESOURCE_FILENAME).Resource.xls;             \
        $(MV) $(LOG_PATH)/$(PROJECT_NAME)_resource.xml $(LOG_PATH)/$(CLEAN_RESOURCE_FILENAME).Resource.xml;             \
        if [ -d $(subst \,/,$(RESOURCE_REPOSITORY)) ] ; then                                                            \
          if [ -d $(subst \,/,$(RESOURCE_REPOSITORY)\$(RESOURCE_TARGETDIR)) ] ; then :;                                 \
          else                                                                                                          \
          $(MKDIR) $(subst \,/,$(RESOURCE_REPOSITORY)\$(RESOURCE_TARGETDIR));                                           \
          fi;                                                                                                           \
          $(call _xcopy,$(LOG_PATH)/$(CLEAN_RESOURCE_FILENAME).Resource.xml,                                            \
                     $(RESOURCE_REPOSITORY)/$(RESOURCE_TARGETDIR))                                                      \
          $(CP) $(RESOURCE_COPYFILES) $(subst \,/,$(RESOURCE_REPOSITORY)\$(RESOURCE_TARGETDIR)) 2>/dev/null;            \
        else                                                                                                            \
          $(ECHO) "Error: Repository path not correct!";                                                                \
        fi;                                                                                                             \
      else                                                                                                              \
        $(ECHO) "Generated files: $(LOG_PATH)/$(PROJECT_NAME)_resource.xml";                                            \
        $(ECHO) "                 $(LOG_PATH)/$(PROJECT_NAME)_resource.xls";                                            \
      fi;                                                                                                               \
      if [ -n "$(GAWK_DEBUG)" ] ; then                                                                                  \
          $(ECHO) "Generating resource debug file: $(LOG_PATH)/$(PROJECT_NAME)_resource_debug.txt";                     \
          $(GAWK) --re-interval -v DEBUG=1 -f fetch-memory-info.awk $(LST_LIST)                                         \
              > $(LOG_PATH)/$(PROJECT_NAME)_resource_debug.txt;                                                         \
      fi;                                                                                                               \
    else                                                                                                                \
        $(ECHO) "Error: GAWK not installed properly. Please update MAKESUPPORT to latest version.";                     \
    fi;                                                                                                                 \
 fi;                                                                                                                    \
 $(RM) fetch-memory-info-meta.txt;                                                                                      \
 $(RM) fetch-memory-info.awk;

#-----------------------------------------------------------------------------
# Size-Rule to generate gsize-output for all Objects.
# Output is also stored in a txt-file in the log-path
#-----------------------------------------------------------------------------
size-all: ;
	@if [ -f != $(OBJ_PATH)/*.* ] ; then                                                                 \
    $(ECHO)"No Object-Files exist to generate SIZE_OUTPUT, please build project or single FILE first"; \
  else                                                                                                 \
    $(foreach obj,$(OBJ_PATH)/*.$(OBJ_SUFFIX),$(GSIZE) $(obj)) &&                                      \
    $(foreach obj,$(OBJ_PATH)/*.$(OBJ_SUFFIX),$(GSIZE) $(obj)) > GSIZE_ALL_OBJECTS.txt;                \
    $(MV) GSIZE_ALL_OBJECTS.txt $(LOG_PATH)/GSIZE_ALL_OBJECTS.txt;                                     \
  fi;

#-----------------------------------------------------------------------------
# Size-Rule to generate Single-Object-File gsize-output.
# Output is also stored in a txt-file in the log-path
#-----------------------------------------------------------------------------
size-%.$(OBJ_SUFFIX): ;
	@if [ -f $(OBJ_PATH)/$*.* ] ; then                                                                              \
    $(GSIZE) $(OBJ_PATH)/$(subst size-,,$@) &&                                                                    \
    $(GSIZE) $(OBJ_PATH)/$(subst size-,,$@) > GSIZE_$(subst size-,,$(subst .obj,,$@)).txt;                        \
    $(MV) GSIZE_$(subst size-,,$(subst .obj,,$@)).txt $(LOG_PATH)/GSIZE_$(subst size-,,$(subst .obj,,$@)).txt;    \
  else                                                                                                            \
    $(ECHO)"  $(OBJ_PATH)/$(subst size-,,$@) does not exists, please build file and retry";                       \
  fi;

##############################################################################
# Include section
##############################################################################

#-----------------------------------------------------------------------------
# generate dependencies automatically
#-----------------------------------------------------------------------------
# List of all targets which don't require dependencies
targets_without_dependencies = nant_setup nant_rm nant_rm_all clean rebuild distclean clean_startAppl deliverydescription dd multi cs help NAnt-files/Gen/%.xml build.xml buildFiles inclists visual10 visual12 visual 

# If new dependency format is used, the depend target will also include the dependency files
# This will cause a reubild of the dependency files if a .c/.h file of the dependency file changes
ifneq ($(NEW_DEPENDENCY_FORMAT),1)
  targets_without_dependencies += depend
endif

# Include dependencies if no target is set => assuming default target is used
# Default target requires dependencies
ifeq ($(strip $(MAKECMDGOALS)),)
  ifneq ($(NEW_DEPENDENCY_FORMAT),1)
    -include $(PROJECT_NAME).dep
  else
    -include $(DEPENDENCY_FILES_FOR_SOURCES_UNIX) $(DEPENDENCY_FILES_FOR_ASM_SOURCES) $(DEPENDENCY_FILES_FOR_BUILD_LIBS)
  endif
else
  # Targets are set
  # Include dependencies only if they are required by a target
  ifneq ($(strip $(filter-out $(targets_without_dependencies),$(MAKECMDGOALS))),)
    ifneq ($(NEW_DEPENDENCY_FORMAT),1)
      -include $(PROJECT_NAME).dep
    else
      -include $(DEPENDENCY_FILES_FOR_SOURCES_UNIX) $(DEPENDENCY_FILES_FOR_ASM_SOURCES) $(DEPENDENCY_FILES_FOR_BUILD_LIBS)
    endif
  endif
endif

##############################################################################
# NAntSupport section
##############################################################################
ifeq ($(NANT_USED),1)
NANT_GEN_FILE = Scripts\make\NAntGen.make

# Set default value for installation directory if it has not been set before
ifeq ($(NANT_TARGET_DIR),)
  NANT_TARGET_DIR = D:\uti\NAntSupport\$(NANT_VERSION)
endif

ifeq ($(NANT_SOURCE_DIR),)
  NANT_SOURCE_DIR = \\vi.vector.int\Backup\PES\DevelopmentTools\DevSupportTools\NAnt\2.13.latest
endif

# Paths to NAntGen.make file
NANT_GEN_MAKE_LOCAL = $(NANT_TARGET_DIR)\$(NANT_GEN_FILE)
NANT_GEN_MAKE_REMOTE = $(NANT_SOURCE_DIR)\$(NANT_GEN_FILE)

# Try to include NAnt-files/version.make, the - prefix ensures that no error
# will be reporte if the file doesn't exist
-include NAnt-files/version.make

# First try to include NAntGen.make from local directory
ifneq ($(strip $(wildcard $(NANT_GEN_MAKE_LOCAL))),)
NANT_SETUP_ROOT = $(NANT_TARGET_DIR)
-include $(NANT_GEN_MAKE_LOCAL)
else
# If include from local directory didn't work, use installer from network
NANT_SETUP_ROOT = $(NANT_SOURCE_DIR)
-include $(NANT_GEN_MAKE_REMOTE)
endif

endif #ifeq ($(NANT_USED),1)
#-----------------------------------------------------------------------------

#End of Global.Makefile.target.make
